Iam trying to run a java file(editor.java) from another java program(exec.java). It takes input and displays file not found message.please give me suggestion through which I run a progam succesfully.
import java.io.*;
public class exec {
public static void main(String argv[]) {
try {
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
System.out.println("Enter the java class name");
String s=br.readLine();
String[] cmd = {"java", "-cp", "E:\netbeans\Project\src", s};
Process pro=Runtime.getRuntime().exec(s);
try (BufferedReader in = new BufferedReader(new InputStreamReader(pro.getInputStream()))) {
String line=null;
while((line=in.readLine())!=null) {
System.out.println(line);
}
}
} catch(Exception err) {
err.printStackTrace();
}
}
java.io.IOException: Cannot run program "editor.java": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at java.lang.Runtime.exec(Runtime.java:615)
at java.lang.Runtime.exec(Runtime.java:448)
at java.lang.Runtime.exec(Runtime.java:345)
at project.exec.main(exec.java:18)
editor.javaas commadline argument?