System.setProperty scope in Tomcat

This question is the "cousin" of this Android related one . But here we are in the Tomcat environment .

If in my webapp I set a property with System.setProperty("property_name", "property_value"); What area will it be applied to?

  • all jvm in this machine
  • all Tomcat web pages
  • only webapp executing the statement
  • only thread executing the command
  • something else...

Many thanks!

+7
source share
2 answers

The system property has a JVM scope. Thus, the property will be changed (and available) in the entire JVM for all web applications and Tomcat itself.

Please note that the system property is stored in memory and thus is not saved if you stop and restart Tomcat.

+5
source

In Java, System.setProperty() always applied to the entire JVM.

So yes, this will affect the whole instance of Tomcat, including all webapps.

+1
source

All Articles