File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is System.setProperty?

 
Phillipe Rodrigues
Ranch Hand
Posts: 165
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
with the execution of the below command where is the value set in the system?

System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
 
Rob Spoor
Sheriff
Pie
Posts: 20380
45
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Memory only. Next time you start your application, this property will be gone.
 
Saurabh Deshpande
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,

Can you tell me if this System.setProperty will get set for the entire application or only for the method or class that it is invoked in?

My concern is I have System.setProperty done for Connection timeout.
And i want to have it for 1 specific url only and not for all the urls.

So, if I set this property in one method or class will it apply for all the URL connections?

Saurabh.
 
Bob Ruth
Ranch Hand
Posts: 320
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From my research here, these properties can be persisted but how it happens is dependent on your operating system.

First there are system and user properties and they can be managed separately.

On Linux/Unix they are written to XML files in a hierarchical file that matches the package path. On a Windows platform they are actually stored in the registry and the user properties are separate for each user.

It allows a way for you to add the notion of user and system preferences to an application and have those preferences persist across logins.
 
Paul Clapham
Sheriff
Pie
Posts: 20184
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Saurabh Deshpande:
Can you tell me if this System.setProperty will get set for the entire application or only for the method or class that it is invoked in?
You could easily test this for yourself. In one method, call System.setProperty("test", "answer") and in another method, call System.getProperty("test") and see what you get.

Alternatively, ask yourself how something could be maintained just for the execution of one method without assigning a value to a local variable within that method.
 
Rob Spoor
Sheriff
Pie
Posts: 20380
45
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bob Ruth:
From my research here, these properties can be persisted but how it happens is dependent on your operating system.

First there are system and user properties and they can be managed separately.

On Linux/Unix they are written to XML files in a hierarchical file that matches the package path. On a Windows platform they are actually stored in the registry and the user properties are separate for each user.

It allows a way for you to add the notion of user and system preferences to an application and have those preferences persist across logins.

Aren't you mixing the System properties with java.util.Preferences? That's the one that is using the registry in Windows. I never heard of the System properties being written to the registry. I also just checked the Java 6 code for System and it's just a regular java.util.Properties object.
 
Bob Ruth
Ranch Hand
Posts: 320
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoops, I do indeed stand corrected. My bad.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic