开发者

Scope of System.setProperty in Tomcat

开发者 https://www.devze.com 2023-04-09 23:56 出处:网络
This question is "cousin" of this one involv开发者_高级运维ing Android. But here we are in Tomcat environment.

This question is "cousin" of this one involv开发者_高级运维ing Android. But here we are in Tomcat environment.

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

  • all JVM in this machine
  • all Tomcat webapps
  • only the webapp that executes the instruction
  • only the thread that executes the instruction
  • something else...

Many thanks!


A system property has a JVM scope. The property will thus be modified (and available) in the whole tomcat JVM, for all the webapps and for Tomcat itself.

Note that the system property is stored in memory, and will thus not persist if you stop and restart Tomcat.


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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号