The class com.sun.tools.javac.Main.compile provides the programming interface for javac.
sample code is :int errorCode = com.sun.tools.javac.Main.compile(new String[] {
"-classpath", "bin",
"-d", "/temp/dynacode_classes",
"dynacode/sample/Foo.java" });
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 com.sun.tools.javac.Main
public static int compile(String[] args);
public static int compile(String[] args, PrintWriter out);
Wednesday, October 18, 2006
Java:Programmatically compiling a java file
Subscribe to:
Post Comments (Atom)
1 comment:
Nice post, Thanks for sharing the informative information.
Java Online Training
Java Online Training In Chennai
Core Java Online Training
Post a Comment