我正在尝试安装Apache Tomcat,需要设置环境变量,该如何设置环境变量?我尝试使用ProcessBuilder,但它没有起作用。
ProcessBuilder pb = new ProcessBuilder("CMD.exe", "/C", "SET"); // SET prints out the environment variables
pb.redirectErrorStream(true);
Map<String,String> env = pb.environment();
String path = env.get("CATALINA_HOME") + apachePath;
env.put("CATALINA_HOME", path);
Process process = null;
try {
process = pb.start();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}