Search code examples
javatomcatlifttomcat5.5

How to pupulate System.getProperty() in Tomcat 5.5


I am trying to set a system property in tomcat config file so it can be read by System.getProperty() code. This is probably a simple task but I am not able to figure this out. Here is want I tried with no success.

Modified context.xml in tomcat settings.

<Context>
      ....
     <Parameter name="run.mode" value="test"/>
     <Environment name="run.mode" value="test" type="java.lang.String"/>
</Context>

I don't want to modify container settings, just the server settings.

PS. I am fairly new to to the container and JVM webapp world. Still making sence of things. Right now I am working with Lift.


Solution

  • Use the JAVA_OPTS environment variable when launching Tomcat, like this:

    JAVA_OPTS='-Drun.mode=test' start.sh