Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System Properties!!

 
Brian Smith
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
could someone please explain me the use of system properties class that java provides? some of the books says that System properties are another mechanism used to parameterize a program at run time. but i can't see how? please help me.
thanks.
 
Anupama Dande
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think u should better go thru the following site, which explains neatly about the usage of the System Properties (i.e., Accessing System Resources at Runtime).
http://java.sun.com/docs/books/tutorial/essential/system/properties.html
It's nifty to work with this... Enjoy urself too...
 
Brian Smith
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
like you suggested, i read about the system properties class in the following site.
Originally posted by Anupama Dande:
I think u should better go thru the following site, which explains neatly about the usage of the System Properties (i.e., Accessing System Resources at Runtime).
http://java.sun.com/docs/books/tutorial/essential/system/properties.html


But i still can't see how we can make use of this feature to parameterize a program at run time. could you please give me some real world instances we could make use of this features?
Also, when i read an example, this features let us know things like "file.separator","java.class.path","java.class.version","os.name"...etc. why do we need to know these at run time?
please help me.
thanks.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi sathi
Also, when i read an example, this features let us know things like "file.separator","java.class.path","java.class.version","os.name"...etc. why do we need to know these at run time?
we need to have them at run time in case we want to migrate code across various platforms.
for e.g. if we code using file separator as "/" which is for Unix based systems then we have to change it when we give our program to a friend running windows as the file separator is "\" on windows.
well, u might think this is just a little change but its better to avoid that as well in cases when v r going to provide the compiled classes ONLY to the others for running them and we don't know which system they have...
to give u an example of the use of "runtime" properties,
there r some java properties which certain APIs uses and we can specify their values using switches like "-D" at runtime. u can go to,
RMI tutorial page which one of the many examples how ppl use "-D" switch and specify property values at run time for,
java.rmi.server.codebase etc...
u can use those properties with System.getProperty("java.rmi.server.codebase") as well...u know..
hope u c some direction here
regards
maulin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic