嗨,我一直在努力让“getenv”工作。它将继续返回“线程“main”java.lang.UnsupportedOperationException中的异常”。我一直在阅读有关 ProcessBuilder 的信息,但我不太确定根据下面的代码如何以及在何处实现它。
我想要做的是,在满足条件时设置一个变量(“REGRESSION_STATUS”,“UPDATED”)和(“REGRESSION_STATUS”,“OUTDATED”),并根据需要返回值“UPDATED”和“OUTDATED”在 Windows 中通过 cmd 执行时。
public static void main(String[] args) throws ClassNotFoundException {
String run_type = args[0];
String inputFile = args[1];
System.out.println("RUN TYPE = " + run_type);
System.out.println("INPUT FILE = " + inputFile);
MiniData data = getValue(run_type, "LEM");
if(run_type.equals("BUILD")){
System.out.println("Script = " + data.getScript());
}
else if (run_type.equals("DEPLOY")){
System.out.println("Script = " + data.getScript());
}
else if (run_type.equals("REGRESSION")){
System.out.println("Runtime Version (DB) = " + data.getRuntime());
String file_name =inputFile;
if(data.getRuntime().equals(getRuntimeVersion(file_name)))
{
System.out.println("The version is up-to-date");
System.getenv().put("REGRESSION_STATUS", "UPDATED");
System.getenv().put("REGRESSION_VER", data.getRuntime());
}
else
{
System.out.println("This version is outdated");
System.getenv().put("REGRESSION_STATUS", "OUTDATED");
System.getenv().put("REGRESSION_VER", data.getRuntime() );
}
}
else {
System.out.println("You have not the correct value. Enter either BUILD/DEPLOY/REGRESSION");
}
}
谢谢!