gcj: accessing environment variables

erik poupaert erik.poupaert@chello.be
Thu May 1 00:36:00 GMT 2003


Thanks for your workaround.

This time around, I think I will manage to complete things without using
environment variables.I've just put it onto my list to write a native
method at some point in type that uses CNI to retrieve environment
variables, since I won't be able to avoid it in the future.

By the way, GCJ executables behave marvelously as commandline utilities
that you can script -- as you like -- with bash. No excessive startup
times, no strange invokation methods a la "java -jar ...". I just love
it!

On Thu, 2003-05-01 at 01:30, Nic Ferrier wrote:
> Mohan Embar <gnustuff@thisiscool.com> writes:
> 
> > 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?
> 
> <start of rant>
> I'd just like to reiterate how much I personally hate this about
> Java. Environment variables are a great tool in software
> configuration management. I use them all the time. Using the property
> trick is one way round things, but I would much prefer to use a real
> environment variable.
> 
> And I don't really care about portability for environment
> variables. They're a unix feature and that's where I use them.
> <end of rant>
> 
> Apologies. Had to get that off my chest.
> 
> 
> Nic
> 
> 



More information about the Java mailing list