Search code examples
javabashenvironment-variablesprocessbuilder

Setting a java ProcessBuilder environment with a bash script


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?


Solution

  • 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.