Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-06-2006, 01:43 PM   #1
LQ Newbie
Registered: Dec 2006
Posts: 2

Rep: Reputation: 0
Setting default parameters for commands

I'm quite new to linux and am trying to set up java (JDK) on a virtual server via SSH.
Although I've installed the JDK, I need to limit it's memory whenever it's run from the ssh terminal window AND by other applications.
To do this I need the parameters '-server -Xms16m -Xms32m' to be automatically included whenever java is run.
I've tried setting JAVA_HOME and JAVA_OPTS variables via editing ~/.profile however this has no effect.
I also tried renaming the executable and creating an alias, which worked fine for when I ran java from ssh terminal, however when apache ant tried to use java it looks directly for the java executable (alias doesn't work).
I'd really appreciate any help that can be given, as it seems like it should be a relatively easy thing to do (?)
The version of linux being run is Red Hat enterprise 3.
Old 12-06-2006, 01:59 PM   #2
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
if this is when the "java" command itself is run, you can always just use an alias:

alias java='java -server -Xms16m -Xms32m'

in your ~/.profile or ~/.bashrc

but there may be a more java specific way to achieve this.
Old 12-06-2006, 02:05 PM   #3
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
You could write a wrapper script and call that instead of java directly. It might contain something like this:

exec java.orig -server -Xms16m -Xms32m "$@"
Rename the original java to java.orig, and put this script where the original was...
Old 12-06-2006, 06:18 PM   #4
LQ Newbie
Registered: Dec 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you both for your suggestions.
I had tried to create an alias before - and as pointed out, it only worked from the command line.
Writing the wrapper script has enabled me to do what I was after.
Thanks again


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing default module parameters at boot time icpsvt Linux - General 3 02-11-2006 08:03 PM
Default Boot Parameters in GRUB? JoshArldt SUSE / openSUSE 9 01-30-2006 03:48 AM
eth0 losing link shortly after 'setting network parameters' on boot scylla Linux - Networking 1 04-13-2005 10:11 AM
Use parameters as default? krock923 Linux - General 2 09-10-2004 06:20 PM
setting default page size and default tray lived4eva Linux - General 1 11-04-2003 03:39 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:11 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration