This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: gcj: accessing environment variables
- From: Mohan Embar <gnustuff at thisiscool dot com>
- To: java at gcc dot gnu dot org, erik poupaert <erik dot poupaert at chello dot be>
- Date: Wed, 30 Apr 2003 18:21:56 -0500
- Subject: Re: gcj: accessing environment variables
- Reply-to: gnustuff at thisiscool dot com
Erik,
>I was going to read an environment variable MYPERSONALENVVAR and I tried
>to access its value with System.getenv(), until I discovered that
>System.getenv() throws a "deprecated" exception, and that I should use
>System.getProperty() instead.
>
>Then I tried to read System.getProperty("MYPERSONALENVVAR"), just to get
>a null in return.
>
>Does anybody know how I can get hold of environment variables in gcj?
Standard practice for passing system environment variables through to Java
is through a formalism like this:
Unix : java -DMYPERSONALENVVAR=$MYPERSONALENVVAR MyClass
Win32: java -DMYPERSONALENVVAR=%MYPERSONALENVVAR% MyClass
You can then get at the environment variable via System.getProperty("MYPERSONALENVVAR")
For gcj-generated executables, why not just pass the system environment variable
as a command line parameter?
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/