Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to configure java in unix to always add a JRE parameter whenever java is run? e.g. -Dcom.sun.management.jmxremote.port=25800

share|improve this question
add comment

3 Answers 3

You can create a wrapper script and add it to your path. Something like this

#!/bin/bash                                                                                               

java -Dcom.sun.management.jmxremote.port=25800 "$@"  

Call it java-local.sh or some other fancy name and just use it in place of the java binary. Of course this one is pretty basic but I am sure it caters for like 90% of the cases. As a shell exercise, you could make it an alias for your user (but then it only works for your user):

# alias java='java -Dcom.sun.management.jmxremote.port=25800'
share|improve this answer
    
+1 Recommend double-quoting $@ to preserve arguments in the face of whitespace. (Sorry, I'd have edited that in myself, but I have repeatedly, comically, and miserably failed the CAPTCHA.) –  pilcrow Aug 18 '12 at 15:02
add comment

IBM java has support for a SystemDefault.properties file, where each line specifies one Java system property or command line option. but I can't see anything similar for the oracle JDK, and there is a similar thread gone unanswered here;
https://forums.oracle.com/forums/thread.jspa?threadID=2131751

stracing openjdk during startup, seems to indicate that it does not look for any ".properties" files, so I am guessing that the answer is no. But there might be a Java expert come along with a better answer.

share|improve this answer
add comment

You could create an alias

alias java='java -Dcom.sun.management.jmxremote.port=25800'

You could also play around with Application Resource Files which may be more appropriate.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.