• 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

Accessing Enviroment Variable

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to access an enviroment variable from Java.
Meaning: I set (in Win2k) an enviroment variable:
My Computer -> Properties -> Advanced -> Enviroment Variables -> System Vars.

This does not reflect in System.getProperties()

Is there a way I can access that, or god forbid the registry?

In general I want to access a variable in a manner that will be platform independant.

Thanks!
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

The usual method is to pass the enviroment variable to the application when invoking java by using the -D command line argument. You would do this in the script or batch file which sets up your enviroment and launches the applcation.

HTH,
Abhik.

Originally posted by Azriel Abramovich:
I am trying to access an enviroment variable from Java.
Meaning: I set (in Win2k) an enviroment variable:
My Computer -> Properties -> Advanced -> Enviroment Variables -> System Vars.

This does not reflect in System.getProperties()

Is there a way I can access that, or god forbid the registry?

In general I want to access a variable in a manner that will be platform independant.

Thanks!

 
Azriel Abramovich
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, but I have failed to mension that I am running on a J2ee server and thus cannot control the startup script. More than that, it is a production system and the customer would be quite unhappy to stop it just to change the value of the param.

Any idea (other than JNI)?
reply
    Bookmark Topic Watch Topic
  • New Topic