Archives: Tools

Programmatically Compile a Java Class

This example using the Java Compiler API introduced in JDK 1.6 to programmatically compile a Java class. Here we’ll compile the

The simplest way to compile is by calling the run() method of the JavaCompiler and passing the first three arguments with null value. These three argument will use the default, System.out and System.err. The final parameter is the file of the Java class to be compiled.