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.
(as pointed out @sergey tachenov in comments, needs jdk installed necessary tools.jar file comes jdk not jre.)
Comments
Post a Comment