Compiling external .java files from within Java -


i making tool write .java files, (hopefully) compile files .class files. in 1 process, user selects file directory multiple .java files written. want program compile these java files.

javacompiler friend. check documentation here

and here example on how use compiler api

javacompiler compiler = toolprovider.getsystemjavacompiler(); diagnosticcollector<javafileobject> diagnostics = new diagnosticcollector<>(); standardjavafilemanager filemanager = compiler.getstandardfilemanager(diagnostics, null, null); iterable<? extends javafileobject> compilationunits = filemanager.getjavafileobjectsfromstrings(arrays.aslist("youfiletocompile.java")); javacompiler.compilationtask task = compiler.gettask(null, filemanager, diagnostics, null,         null, compilationunits); boolean success = task.call(); filemanager.close(); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -