• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting persitent system environment variables using java program

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic