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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -