After having read a lot of similar questions about Runtime.exec and Java, I've not encountered a safe and clean idiom for compiling and running a .java file. I have just finished reading the "When Runtime.exec() won't" article, which helped me understand the general do's and don't's, but does not provide this idiom I'm looking for.
Overall I'm trying to create separate processes that will compile and run in series (multiple servers), without hanging or leaving any orphan processes. I'm not well-versed with these topics, so I am looking for more pointers.
So far I am able to compile the file by doing this:
try {
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("javac Server.java");
int exitVal = proc.waitFor();
System.out.println("Process exitValue: " + exitVal);
} catch (Throwable t) {
t.printStackTrace();
}