• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set the System variable on WINDOWS and UNIX?  RSS feed

 
Jamy Wang
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there some methods to set the system variable on Windows and UNIX?
I think it must be done by Runtime.exec(cmd). And my question is what's the cmd?
 
Jamy Wang
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And more, I want to change the system variable persistent, not just a time.
 
Jamy Wang
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
help me!
How to set the system variable persistently on Windows or UNIX?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If by "system variable" you mean "environment variable" the answer is that you can't, at least not portably. On UNIX you might conspire to edit the user's .profile or .cshrc or .bashrc or .tcshrc file (each of which can use a different syntax!) On Windows, you'd need a small auxilliary program or bit of native code to put the values into the registry. And then, of course, you're forgetting Macs.
Can I ask why you want to do this?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!