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

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -