/** * @return an array of strings, made up of all the environment variables available in the VM, format var=value. To be * used for Runtime.exec(cmd, envp) */ public static final String[] getEnvironmentVariablesForRuntimeExec() { Properties sysprops = new Properties(); sysprops.putAll( getEnv() ); sysprops.putAll( System.getProperties() ); addInternalVariables( sysprops ); String[] envp = new String[sysprops.size()]; List<Object> list = new ArrayList<Object>( sysprops.keySet() ); for ( int i = 0; i < list.size(); i++ ) { String var = (String) list.get( i ); String val = sysprops.getProperty( var ); envp[i] = var + "=" + val; } return envp; }