title: How to pass a system property to a web application hosted in Tomcat 7 running as a Windows Service?
body: <p>There are numerous places on the Internet, suggesting that it is easily achieved by any (or all) of the following methods:</p>
  
  <ol>
  <li>through <code>CATALINA_OPTS</code></li>
  <li>through <code>JAVA_OPTS</code></li>
  <li>through <code>TOMCAT_OPTS</code></li>
  <li>by placing the <code>set</code> statements in the <strong>setenv.bat</strong> file inside the tomcat's bin folder</li>
  </ol>
  
  <p>My problem, is that I have tried all of the above and my web application still does not see my system property!</p>
  
  <p>Here is what I am doing:</p>
  
  <ol>
  <li>Stop tomcat7 service</li>
  <li>set <code>CATALINA_OPTS=-Dabc.def=true</code> in the system environment</li>
  <li>set <code>JAVA_OPTS=-Dabc.def=true</code> in the system environment</li>
  <li>set <code>TOMCAT_OPTS=-Dabc.def=true</code> in the system environment</li>
  <li>put all of the above into <strong>c:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\setenv.bat</strong> (seems totally redundant, but just in case)</li>
  <li>Start tomcat7 service</li>
  <li>Inspect the environment of the tomcat7 process using the Process Explorer tool - the environment is correct, I do see both <code>CATALINA_OPTS</code> and <code>JAVA_OPTS</code> and <code>TOMCAT_OPTS</code> equal to <code>-Dabc.def=true</code></li>
  <li>run my web app, which is a simple servlet dumping all the system properties to the response stream - <strong><code>abc.def</code> is not amongst them</strong></li>
  </ol>
  
  <p>Please, put me out of my misery and tell me how to do it.</p>