File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes System Property Setting and JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "System Property Setting and JVM" Watch "System Property Setting and JVM" New topic

System Property Setting and JVM

Gil Li

Joined: May 27, 2004
Posts: 15
Hello people..
I have set a value to System property like

in one servlet and I got exactly the value of the key "name" in
another servlet by using..


But When I do this in normal java file and access the value in anotherjava file I did not get the value.It returns null.Actually when we set theSystem Property value that will be stored in JVM. So why that value is notget in ordinary java files.It works well in servlets.Please clear my doubt.

Regards,<br /> <br />GILLI
Anupreet Arora
Ranch Hand

Joined: Jun 17, 2003
Posts: 81
Hi Gil,

The explanation for this is that servlets are deployed in a servlet container and they use the JVM of the container. So if many servlets are deployed in the same container, they are using the same JVM . Hence different servlets can see the same JVM specific system property.

This is not the case for simple java programs. Each execution is in a separate JVM. So the system property you are adding to the JVM gets lost after the execution.

I agree. Here's the link:
subject: System Property Setting and JVM
It's not a secret anymore!