For Compilation
// import
import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
try {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
// set ur java file path
int result = compiler.run(null, null, null, "BaseClass/Hello.java");
}
catch(Exception e)
{
e.printStackTrace();
}
For Jar creation
try {
String command = "jar cvf MyFirst.jar BaseClass" + File.separatorChar;
Process p = Runtime.getRuntime().exec(command);
}
catch (Exception ex) {
ex.printStackTrace();
}
No comments:
Post a Comment