Search code examples
javatomcat8startupjvm-arguments

JVM Options while running Tomcat8 using startup.bat on windows


I want provide some JVM options to my application. The application is a web application and packaged as war. I am using Tomcat8 to deploy this war. I want to provide JVM options while running tomcat using statup.bat file.

I can run the application successfully using eclipse. The eclipse Server configuration has provision to supply JVM arguments using launch configuration.

I tried below ways to supply JVM options.

  1. Using setenv.bat in bin directory with command set JAVA_OPTS=".........". example - I tried below commands in setenv.bat file separately.
    set JAVA_OPTS="-Ddp.registry.local=false -Ddp.registry.logon.id=dpconf -Ddp.registry.logon.pwd=password-Ddp.registry.host.address=ltest16.sto1.3s.intern -Ddp.registry.appid=1234 -Ddp.registry.execunit=BillingDataProvider -Ddp.registry.instance=bdp -Ddp.registry.instance.lowercase=bdp -Ddp.registry.host.port=3700 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Djava.util.prefs.PreferencesFactory=com.smarttrust.common.mechanism.prefs.RegistryJasapPreferencesFactory -Ddp.log.root=C:/Users/dir/softools/apache-tomcat-8.0.5/logs -Ddp.server.log.root=C:/Users/dir/softools/apache-tomcat-8.0.5/logs -Dota.sc.log.root=C:/Users/dir/softools/apache-tomcat-8.0.5/logs -Dlog4j.configuration=file:C:/Users/dir/softools/apache-tomcat-8.0.5/logs/log4j.xml -Djava.util.logging.config.file=C:/Users/dir/softools/apache-tomcat-8.0.5/logs/bdp-log.properties"
    set CATALINA_OPTS="-Ddp.registry.local=false -Ddp.registry.logon.id=dpconf -Ddp.registry.logon.pwd=password -Ddp.registry.host.address=ltest16.sto1.3s.intern -Ddp.registry.appid=1234 -Ddp.registry.execunit=BillingDataProvider -Ddp.registry.instance=bdp -Ddp.registry.instance.lowercase=bdp -Ddp.registry.host.port=3700 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Djava.util.prefs.PreferencesFactory=com.smarttrust.common.mechanism.prefs.RegistryJasapPreferencesFactory -Ddp.log.root=C:/Users/dir/softools/apache-tomcat-8.0.5/logs -Ddp.server.log.root=C:/Users/dir/softools/apache-tomcat-8.0.5/logs -Dota.sc.log.root=C:/Users/dir/softools/apache-tomcat-8.0.5/logs -Dlog4j.configuration=file:C:/Users/dir/softools/apache-tomcat-8.0.5/logs/log4j.xml -Djava.util.logging.config.file=C:/Users/dir/softools/apache-tomcat-8.0.5/logs/bdp-log.properties"
  1. exporting the JAVA_OPTS like set JAVA_OPTS="....." on command prompt before running startup.bat. Above commands exported on command prompt before running startup.bat.

  2. Using context.xml file for example -

        <context>
         .....................
        <Environment name="dp.registry.local" value="false" type="java.lang.String"/>
         ........................
        </context>

But no luck. I am not sure what mistake I am doing.


Solution

  • Issue is with double quotes. While exporting from command prompt do not use double cotes. Just do set JAVA_OPTS=-D..... -D.... Space separated list of options.

    If you echo the java_opts from catlina.bat , it will give you a clear picture.