Reputation: 62876
There are numerous places on the Internet, suggesting that it is easily achieved by any (or all) of the following methods:
CATALINA_OPTS
JAVA_OPTS
TOMCAT_OPTS
set
statements in the setenv.bat file inside the tomcat's bin folderMy problem, is that I have tried all of the above and my web application still does not see my system property!
Here is what I am doing:
CATALINA_OPTS=-Dabc.def=true
in the system environmentJAVA_OPTS=-Dabc.def=true
in the system environmentTOMCAT_OPTS=-Dabc.def=true
in the system environmentCATALINA_OPTS
and JAVA_OPTS
and TOMCAT_OPTS
equal to -Dabc.def=true
abc.def
is not amongst themPlease, put me out of my misery and tell me how to do it.
Upvotes: 6
Views: 7221
Reputation: 3363
I know this post is almost 9 years old but thought someone might find this useful.
Although @prunge and @mark answers were very accurate and following their logic I was able to add system properties to my tomcat 7 instance running on Windows, there is an easier way.
In the installation directory of Tomcat there is an exe you can run called
%INSTALL_DIRECTORY%\bin\tomcat7w.exe
This opens up a Tomcat properties windows where you can control the service i.e. start and stop tomcat and there is a tab (Java) that allows you to set the Java properties as well
Scroll to the end of that panel under "Java Options" and add your system properties
-Dpropertyname=value
Then navigate back to the General tab and restart tomcat
I have tested this and my grails app now can see my properties. I use the following Groovy code to get the property out
System.properties.getProperty("propertyname")
Adding the system properties in the Windows registry showed up in this window as well so its one and the same thing, just this application seems to me to be slightly more convenient.
Hope this helps someone else
Upvotes: 0
Reputation: 23268
For the Tomcat service, startup settings are stored in the registry under Options
key at:
HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\Tomcat<X>\Parameters\Java
(substitute appropriate Tomcat version where needed).
Edit:
On 64-bit Windows, the registry key is:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\Tomcat<X>\Parameters\Java
even if Tomcat is running under a 64-bit JVM.
Upvotes: 9