[Q] How to find Environment Variables?

  • Thread starter Michael T. Peterson
  • Start date
M

Michael T. Peterson

Hi,

Does J2SE provide a standard class or facility for obtaining the values of
environment variables (e.g., as declared in a shell script)? I guess I'm
looking for something analogous to the System.Properties class, but for
environment symbols in the user's process space.

Thanks,

Michael
 
C

Christophe Vanfleteren

Michael said:
Hi,

Does J2SE provide a standard class or facility for obtaining the values of
environment variables (e.g., as declared in a shell script)? I guess I'm
looking for something analogous to the System.Properties class, but for
environment symbols in the user's process space.

Thanks,

Michael

No, there once was support for that, but it has been removed (not all
platforms had environment variables).

Now, you can define extra properties usingh the -Dpropertyname=value syntax.

eg java MyClass -Dhttp.proxyHost=www.proxy.com
 
C

Chris Riesbeck

Roedy Green said:

With regard to that entry, if you care, the answer for how to set
environment variables on the Mac is to use JBindery pre Mac OS X
and use normal Unix export in Mac OS X.

Also, I'm curious why you put the Properties class third in the list
of how to access those variables. Shouldn't it come before non-portable
approaches like JNI?
 
R

Roedy Green

With regard to that entry, if you care, the answer for how to set
environment variables on the Mac is to use JBindery pre Mac OS X
and use normal Unix export in Mac OS X.

the entry now reads:

For the Mac, I don't know how it works. I am told you use JBindery pre
Mac OS X and use normal Unix export in Mac OS X. Sorry I can give you
no more detail than that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top