Paul Reavis wrote:
> So I tried to access an environment variable for the first time today;
> no soap. Since System.getenv() is deprecated, I used
> System.getProperty(). I couldn't get it to fetch my variable with what I
> thought was the correct way:
>
> bash$ export foo=bar
> bash$ java myapp
>
> However I can get it with:
>
> bash$ java -Dfoo=bar myapp
>
> What am I doing wrong here?
Nothing. It's intentional... Java considers environment varables to be too
non-portable.
A little bit of shell or perl (or name-your-favorite-command-interpreter)
programming could give you a script that would construct a Java
command-line containing all of the environment variables as "-D..."
options. I've attached a perl script that'll send a Java command line to
stdout; with a little modification, it could execute the line instead.
To use:
envjava.pl <java arguments...>
it'll spit out a command-line you can send to a shell.
Nathan Meyers
[EMAIL PROTECTED]
envjava.pl