Test1_Exec.java
import java.io.IOException;
public class Test1_Exec {
public static void main(String[] args) throws IOException {
Runtime run = Runtime.getRuntime();
try {
Process p = run.exec("java -cp bin Test1");
} catch (IOException e) {
e.printStackTrace();
}
}
}
Test1.java:
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Test1 {
public static void main(String[] args)
{
FileOutputStream fOut = null;
try {
fOut = new FileOutputStream("d:\\ppp\\Test1.txt");
fOut.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Test1_Exec.class と Test1.class は両方とも JavaTest(プロジェクト名) の下の bin フォルダーにあり、コードは機能します。しかし、 bin フォルダーを追加してコード"Process p = run.exec("java -cp bin Test1")"
を置き換えたいのですが、新しいコードでは作成されません。では、どこに問題があるのでしょうか?"Process p = run.exec("java Test1")"
( right clikcing JavaTest(project name)->Run As->Run Configuration | Tab Classpath --- User Entries --- Advanced --- Add Folders )
Test1.txt