Search code examples
javacommand-lineargumentsjmx

Possible to write command properties in a file


I need to run a Java programme with JMX feature, so the command would be similar like :

java -Dcom.sun.management.jmxremote.port=10200 -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=jmxremote.password -Dcom.sun.management.jmxremote.access.file=jmxremote.access

this makes the command line too long, is it possible to write the properties in a file, in order to shorten the command? Or any other solutions will be welcome!


Solution

  • You can use property file (management.properties) which contains all the JMX options as shown below.

    com.sun.management.jmxremote.port=10200
    com.sun.management.jmxremote.authenticate=false
    com.sun.management.jmxremote.ssl=false
    ....
    

    But you have to tell where the JMX properties are available for the JVM by

    java -Dcom.sun.management.config.file=c:\management.properties