I thought when the java program launches a seperate child process, the contents of the java library path would be added to the Path environment variable and would be available for the child process. But I dont see this happening.
Something seems confusing. I tried the following program
When I compile as javac Test.java and run as java Test , I get the following output
Parent process info :
PATH environment variable from System Properties : null
java.library.path environment variable from System Properties : C:\Java\jdk1.6.0
Child process info :
PATH environment variable from Child Process Builder environment : C:\Java\jdk1.
java.library.path environment variable from from Child Process Builder environme
nt : null
The above implies that the PATH variable is not available through the System Properties but somehow it gets set for the environment if a child process is created through ProcessBuilder. Also the java.library.path is not automatically transferred from the parent process to the environment of the child process.
Is that the desired behavior?
PS Contents of my PATH variable when echoed from DOS is C:\Java\jdk1.6.0_04\bin
author and iconoclast
System properties are not at all the same as environment variables. Environment variables are not copied into system properties, and system properties are not copied into environment variables. Although the default variables of some system properties might come from environment variables on some platforms, this is a platform-specific implementation detail.
They mean to say that you should pass system-dependent arguments to Java programs using "-DFOO=bar" rather than by using an environment variable named FOO.
Joined: Oct 11, 2009
Thanks for the response.
If the getEnv method returns environment variables but is merely not supposed to be used to extract System properties, I dont know if it should be marked as deprecated (as in the documentation). A comment there mentioning the usage would be more appropriate unless ofcourse it has been moved to a different class or something.