想问下 Runtime.getRuntime().exec(command, env);中env
具体应该怎么设置,
具体我在一个项目中
command = "javac -nowarn \"" + className + "\" -d \""
+ compiledStubPath + "\" -sourcepath \"" + stubPath + "\"";
String[] env = {"CLASSPATH=" + System.getProperty("java.class.path")
+ File.pathSeparatorChar + libPath};但是不成功想问应该怎么设置
具体应该怎么设置,
具体我在一个项目中
command = "javac -nowarn \"" + className + "\" -d \""
+ compiledStubPath + "\" -sourcepath \"" + stubPath + "\"";
String[] env = {"CLASSPATH=" + System.getProperty("java.class.path")
+ File.pathSeparatorChar + libPath};但是不成功想问应该怎么设置
Process p = run.exec("xxxxxxx");
BufferedInputStream in = new BufferedInputStream(p.getInputStream());
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String s = null;
while ((s = br.readLine()) != null)
System.out.println(s);
String command = " run.bat " + parm;
try {
Process child = Runtime.getRuntime().exec(command);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
建议动态生成bat文件,再调用
String c = "java -classpath E:/workspace/t/bin/ T1";
Process exec = Runtime.getRuntime().exec(c);
BufferedReader r = new BufferedReader(new InputStreamReader(exec.getInputStream()));
System.out.println(r.readLine());
exec.waitFor();我写了这段代码,是对的,可以输出T1类的输出,你参考一下