File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting persitent system environment variables using java program

 
Biju moozhikkara
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai,
Iam tryng to write installation for an application,which require to set some persistent system environment variables using java program. I have tried using set command Runtime.getRuntime().exec("cmd /c set blah blah "),but this applies only to that particular DOS promt only,i presume.And this is not perisistent.please do help.
Biju
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is autoexec.bat still read from Windows? Which windows?
Then open that file, and append your line.
This should take effect on the next boot (no problem: windows users are used to reboot often).

But hasn't it been autoexec.nt for win2k?

Not an java-advanced but general-computing/ beginners question imho.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java's Preferences class will stick stuff in the windows registry for you. Can't be more persistant than that.
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do these values need to be global for the whole system? What if you happen to choose a variable name that is already in use? I suggest that you create a .properties file and use the Properties class to store these values instead. That way they are local to your own program and don't interfere with any global settings that are necessary for the computer to run. Also, this approach will make your software independent of the operating system. The approach you are using now is specific to Windows.

Layne
 
Biju moozhikkara
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mr Stefan Wagner
iam working in windows 2000 env and i dont think there is any autoexec.bat file in window 2003.
Any way i got a break through.Thanks for tour reply.
Biju
Mr Barry Gaunt,
i think Java's Preferences can set values to HKEY_LOCAL_MACHINE/JavaSoft/Prefs only ,it can't
environment variables.please read the question carefully.Thank you
Biju
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic