Hi @trung,
I'm using your library to compile code that's coming from a web interface. After compilation I'm running the compiled class to evaluate the output.
If a user inputs something like System.exit(0);, the server will crash. I tried to prevent this by running the compiled class in a separate process like this:
public static int exec(Class clazz) throws IOException,
InterruptedException {
String javaHome = System.getProperty("java.home");
String javaBin = javaHome +
File.separator + "bin" +
File.separator + "java";
String classpath = System.getProperty("java.class.path");
String className = clazz.getCanonicalName();
ProcessBuilder builder = new ProcessBuilder(
javaBin, "-cp", classpath, className);
Process process = builder.start();
process.waitFor();
return process.exitValue();
}
The problem with this is that I'm getting a "Class not found" error everytime I try to run the compiled class like this.
Is it possible to run the compiled class in a separate process using another way?
Hi @trung,
I'm using your library to compile code that's coming from a web interface. After compilation I'm running the compiled class to evaluate the output.
If a user inputs something like
System.exit(0);, the server will crash. I tried to prevent this by running the compiled class in a separate process like this:The problem with this is that I'm getting a "Class not found" error everytime I try to run the compiled class like this.
Is it possible to run the compiled class in a separate process using another way?