开发者

Environment variables passed by Runtime.exec(String)

开发者 https://www.devze.com 2023-01-27 19:52 出处:网络
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 documenta

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号