import java.io.*;
public class Auto {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
try {
Runtime.getRuntime().exec("javac C:/HelloWorld.java");
Runtime.getRuntime().exec("java C:/HelloWorld > C:/out.txt");
System.out.println("END");
} catch (IOException e) {
e.printStackTrace();
}
}
}
This program is able to compile the 'HelloWorld.java' file, but not execute it(HelloWorld). Could anyone please suggest me how to make it work? Thanks in Advance! :) Also, if the output could be able to be taken in another text file say 'output.txt'.
java c:/HelloWorld.