|
From: Leif M. <le...@ta...> - 2004-11-26 03:40:49
|
Jason,
What you asking is not currently possible with the Wrapper. The
closest thing you
could do would be to pass the environment variable to the JVM using a system
property as follows:
wrapper.java.additional.1=-Denvironment.MYENV=%MYENV%
You can then access it as System.getProperty( "environment.MYENV" );
I'm not sure the exact reasons why Java deprecated the System.getenv()
method. That was a Sun decision and nothing to do with the Wrapper.
Now, as to whether or not this would be possible to add to the
Wrapper...
The thing is that the Wrapper process will be given an Environment by
the system
at the time it is created. It then passes on that Environment to the
Java process
when it is launched.
If the user makes any changes to the environment after the processes
are created
they would not be visible until the process is restarted.
As a workaround, the environment variables can be accessed directly
from the
registry. The Wrapper does that to make it possible to run as an NT
service without
requiring a system restart to get the latest environment variables.
Normally the NT
service manager does not update its Environment after it has been
launched at startup.
Any changes to the Environment variables in the System control panel
will therefor
not be visible until the system has been restarted.
A better way to approach this might be to tell me exactly what you
are trying to
do. There may be other ways to accomplish this. As a rule, you should
assume
that environment variables will not be changed during the life of a
given process.
Cheers,
Leif
Jas...@sc... wrote:
>
> Hi,
>
> First off, kudos for such a useful library!
>
> I have a service which handles requests (jobs) from other machines - a
> distributed build process.
>
> My problem is that it needs to know what "tools" (compilers, SDKs) are
> installed locally, which requires the service to check for the
> existence (say) of %SDK_HOME%/sdk.h or %APP%/bin/app.exe
>
> System.getenv() is causing a java.lang.Error in the service, but not
> as an application. Checking the docs it seems to imply that getenv is
> deprecated, but this does not appear to be true going by the javadoc:
> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getenv(java.lang.String)
>
> These variables may not be known at run-time and are subject to change
> and so I would rather not have them hardwired into each client via
> properties...
>
> Any thoughts?
>
>
> Jason Chown
> Head Programmer
> SCEE Studio Liverpool
>
>
> **********************************************************************
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed. If you have received this email in error please notify
> pos...@sc...
>
> This footnote also confirms that this email message has been checked
> for all known viruses.
>
> **********************************************************************
> Sony Computer Entertainment Europe
|