Convert .java to .class within a java program -


this question has answer here:

i have several .java files created during runtime. want use created .java files classes in program. how may this, without starting program second time ? want compile .java files during runtime , use new .class files on...

use java compiler api:

public class simplecompiletest {     public static void main(string[] args) {         string filetocompile = "test" + java.io.file.separator +"myclass.java";         javacompiler compiler = toolprovider.getsystemjavacompiler();         int compilationresult = compiler.run(null, null, null, filetocompile);             if(compilationresult == 0){                system.out.println("compilation successful");            }else{                system.out.println("compilation failed");            }     } } 

detailed example explanation


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -