I want to compile second file and get the output but it throw an Exception .
public static void main(String[] args) throws IOException, InterruptedException {
String path="C:\\Users\\Amr\\Documents\\NetBeansProjects\\Second.java";
Process pro1 = Runtime.getRuntime().exec("javac " + path);
ProcessBuilder ps = new ProcessBuilder("java ", path);
ps.redirectErrorStream(true);
Process pr = ps.start();
BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
pr.waitFor();
System.out.println("ok!");
in.close();
pro1.waitFor();
}
Get output from this class
public class Second {
public static void main(String[] args) {
System.out.println("Hello world from Second.java");
}}
please any help for repairing the errors
that is the error
Error: Could not find or load main class C:\Users\Amr\Documents\NetBeansProjects\Second.java