简体   繁体   中英

Environment variables passed by Runtime.exec(String)

Are the environment variables of the parent process(eg 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 available 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM