我有以下类:
编译我的CreateTexts.java下课后,我想通过getRuntime运行它(通过Eclipse中调用它)。 所以,我跑这个类
public class RuntimeDemo {
public static void main(String[] args) {
try {
// create a new array of 2 strings
String[] cmdArray = new String[2];
// first argument is the program we want to open
//C:\Program Files\Java\jdk1.6.0_20\bin
cmdArray[0] = "C://Program Files//Java//jdk1.6.0_20//bin//java";
// second argument is a txt file we want to open with notepad
cmdArray[1] = "C://logback//CreateTexts";
// create a process and execute cmdArray and currect environment
Process process = Runtime.getRuntime().exec(cmdArray,null);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
但我没有看到正在创建的输出文件。 任何提示appareciated感谢