Environment variables passed by Runtime.exec(String)
Are the environment variables of the parent process(e.g. shell) available in the environment in which a child process that is invoked using Runtime.exec(command) run? I had a look at the API documentation but it's not specified there.
My use case is this
mainScript.sh
invokes java MainClass
MainClass
invokes Runtime.exec("hi.sh")
Now, is a variable MY_ENV
that is set and exported in mainScript.sh
av开发者_如何学Cailable to hi.sh
?
PS: I'm aware of the 2nd API that takes explicit String[] envp
.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4064912 has some vague info.
Yes, why not?
From Runtime documentation:
Every Java application has a single instance of class Runtime that allows the application to interface with the environment in which the application is running
精彩评论