Setting java system properties to a java application

26,968

Solution 1

Use the supplied startup.bat and catalina.bat files instead of calling tonmcat.exe directly. This has always worked for me...

Solution 2

AFAIK, these variables are used by the tomcat startup script and not by Java directly. Here's a link that might help you:

CATALINA_OPTS v JAVA_OPTS - What is the difference?

Solution 3

I managed to do this by running the server from bootstrap.jar in a similiar manner to the way I started notepad.jar.

java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9898 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -jar bootstrap.jar

Apparently catalina.bat and startup.bat do no exists in tomcat6.0. I haven't found proper documentation for the changes from 5.5 to 6.0 which describe the removal of these startup batch files, which is a shame because i'm still not sure i'm doing it the correct way. Although it works which is, I guess, a good start.

Share:
26,968
Ben
Author by

Ben

Updated on July 12, 2022

Comments

  • Ben
    Ben almost 2 years

    Possible Duplicate:
    How can I specify system properties in Tomcat configuration on startup?

    What i'm trying to do, eventually, is to start TOMCAT with certain java system properties set (in this case jmx setup):

    -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9898 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false`
    

    )

    Problem is I don't think i'm doing it right. What I'm doing is, in the command prompt window (Working in Vista 64, BTW) I use:

    set CATALINA_OPTS=-Dcom.sun.management.jmxremote...
    set JAVA_OPTS=-Dcom.sun.management.jmxremote...
    tomcat6.exe
    

    This doesn't seem to work since tomcat6 is not behaving as if the properties were set. To test this I used the example Notepad.Jar that comes with the java jdk. Tried to run it the same way:

    set JAVA_OPTS=-Dcom.sun.management.jmxremote...
    java -jar Notepad.jar
    

    which didn't work, but this did work:

    java -Dcom.sun.management.jmxremote .... -jar Notepad.jar
    

    Since the last attempt did work I concluded that the JAVA/CATALINA_OPTS setup is incorrect.

    Could someone point out what i'm doing wrong? I hope I was clear enough.

    Thanks!

  • Ben
    Ben almost 15 years
    Tnx. I don't have these batch files, are they installed separately? I'm using Tomcat 6.0, perhaps it's different here?