Wednesday, October 18, 2006

Java:Programmatically compiling a java file

The class provides the programming interface for javac.
sample code is :

int errorCode = String[] {
"-classpath", "bin",
"-d", "/temp/dynacode_classes",
"dynacode/sample/" });

errorCode return 0 for Sucess and some non-zero number for any compilation failure.

Also to print the compilation error messages to an o/p file,
it has another overloaded method.

// Defined in
public static int compile(String[] args);
public static int compile(String[] args, PrintWriter out);

1 comment:

Jackie Co Kad said...

Very much useful article. Kindly keep blogging

Java Training in Chennai

Java Online Training India