File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How to manipulate Windows System Variables using Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to manipulate Windows System Variables using Java" Watch "How to manipulate Windows System Variables using Java" New topic
Author

How to manipulate Windows System Variables using Java

rakesh nagar
Greenhorn

Joined: Aug 02, 2001
Posts: 17
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

Joined: Sep 29, 2000
Posts: 8521
System.setProperty(String key, String value);


"JavaRanch, where the deer and the Certified play" - David O'Meara
Wilfried LAURENT
Ranch Hand

Joined: Jul 13, 2001
Posts: 269
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

Joined: Aug 02, 2001
Posts: 17
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

Joined: Jul 13, 2001
Posts: 269
Try this :
Runtime.getRuntime().exec("set CLASSPATH=....");
W.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to manipulate Windows System Variables using Java