Код: Выделить всё
String fileToCompile = "C:/Users/Jeff/Documents/Test/Compiler 6/examplejavafile.java";//Absolute path
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
FileOutputStream errorStream = new FileOutputStream("Errors.txt");
int compilationResult = compiler.run(null, null, errorStream, "-verbose", fileToCompile);
if(compilationResult == 0){
System.out.println("Compilation is successful");
}else{
System.out.println("Compilation Failed");
}
Код: Выделить всё
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
Подробнее здесь: https://stackoverflow.com/questions/109 ... vacompiler
Мобильная версия