Setting a java ProcessBuilder environment with a bash script

点点圈 提交于 2020-01-24 00:39:27

问题


I've been using ProcessBuilder to successfully invoke a process with various environment variables using env.put("VAR","value").

Now I'd like to source some bash scripts to set a whole bunch of environment variables that are not predetermined within java.

Anyone know of an easy way to do this?


回答1:


bash supports the environment variable BASH_ENV on startup. Set the variable to your script and its contents will be sourced before execution. See bash(1) for details.




回答2:


If your "batch scripts" to be sourced are in properties format, you can always load them using Properties and merge into the env.



来源:https://stackoverflow.com/questions/7522057/setting-a-java-processbuilder-environment-with-a-bash-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!