Domanda

What is the scope of System.setProperty()? If I set it in one of the classes in a Java EE application, would all the other classes and other components that use System.getProperty() or use other ways of accessing the property, be able to view the value that has been set?

For example, I am using:-

System.setProperty("catalina.home", "C:");

Later on other a number of xml files look for context in a property file in CLASSPATH which is catalina.home. However, these files cannot find the property file. So I am wondering if I am doing something wrong.

È stato utile?

Soluzione

It has application-wide scope, but it's in memory. More specifically, it's scoped to the runtime. However, once the application ends, it's gone, i.e. changes made to system properties are not persisted.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top