• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get the system property ?

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I would like to get the properties in the System, such as CLASSPATH and PATH. But when I used the following code, it always return null to me. Please help.
Properties p = System.getProperties();
System.out.println(p.getProperty("CLASSPATH"));
Thanks!
qionghua
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
WE talked about that here: http://www.javaranch.com/ubb/Forum33/HTML/002404.html
 
qionghua yang
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Cindy.
Now I can get it by using the following code. But does that mean I always need to
************************************************************
Properties p = System.getProperties();
System.out.println(p.getProperty("java.class.path"));
************************************************************
But when I use this
System.out.println(p.getProperty("java.path"));
System.out.println(p.getProperty("HOMEPATH"));
the value is null. Does that mean I always need to use "java...." as my key?
How can I get the system variables in Settings->Control Panel->System->Environment?
Thanks!
qionghua
reply
    Bookmark Topic Watch Topic
  • New Topic