• Post Reply Bookmark Topic Watch Topic
  • New Topic

System properties  RSS feed

 
anita dhar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the class Prop , how do you read the value of the system property
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by anita dhar:
In the class Prop , how do you read the value of the system property


what is it , Prop ?

You can read the values of system properties from System.getProperty() method.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Campbell Ritchie
Marshal
Posts: 55770
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rahul Bhattacharjee is quite right. You can get a Properties object from the system. There is a method in the Properties class which allows you to get a whole list. Go and look in the API and you can get all the properties for your computer for about 5 minutes' coding.

Except the one for line end; you will have to get that as a String and print out its individual characters as numbers using the %d (or better %x) format tags.
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an example of code that gets a system property:



I'm not sure if the above code gets the version of the Java compiler or of the Java runtime, but I'm working on getting the runtime version to check system requirements.

Here's an example of setting a system property:



I set the above property to select an option in the Mac look-and-feel to make my software more Mac-like on a Mac. I believe that this property is ignored on other platforms so I don't have to do any special-casing.

The following code gets an object of type Properties that contains all of the system properties that are currently defined:



In addition to the properties in this Properties object, there are probably other system properties that you can set, but I believe that these would differ from platform-to-platform and that you would consult the documentation for the particular JVM that you need to set a property for.

Kaydell

[ edited for clarity ]
[ June 23, 2007: Message edited by: Kaydell Leavitt ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!