compiler construction - Compile Java source code from a string? -


this question has answer here:

is there way running java program compile java source code (passed string)?

class newclass = compiler.compile ("class abc { void xyz {etc. etc. } }"); 

ideally, classes referenced passed-in source code resolved program's class loader.

does exist?

sure. have @ javacompiler class , other classes in javax.tools package.

they've been around since java 1.6.

here example code.

(as pointed out @sergey tachenov in comments, needs jdk installed necessary tools.jar file comes jdk not jre.)


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -