Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to manipulate Windows System Variables using Java

 
rakesh nagar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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

 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.setProperty(String key, String value);
 
Wilfried LAURENT
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Try this :
Runtime.getRuntime().exec("set CLASSPATH=....");
W.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic