• 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
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

How to manipulate Windows System Variables using Java

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi There,
I want to manipulate Windows System variables (e.g. PATH, CLASSPATH) using Java program. Could anyone please let me know how it can be done in Java.
Regards,
Rakesh Nagar

 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System.setProperty(String key, String value);
 
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More specifically, the CLASSPATH can be reached by:
String classpath = System.getProperty("java.class.path");

W.
PS: This is a recurrent question...
 
rakesh nagar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your replies...i am aware of the System.get/setProperty. The changes done by System.setProperty are only visible to the current JVM. I want to permanently changes the Windows environment variables.
If possible ? How this functionality can be achieved ?
Thanks in advance
Regards
Rakesh Nagar
 
Wilfried LAURENT
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this :
Runtime.getRuntime().exec("set CLASSPATH=....");
W.
 
reply
    Bookmark Topic Watch Topic
  • New Topic