Search code examples
javacompilationon-the-fly

How to create a method out of the text file?


I have a text (.txt) file that contains Java code! I want to create a method that includes this Java code and then call that method through the program.

Can anybody suggest a way to do this?


Solution

  • let consider this example what it does actually load the source code, compile and execute the java code by simpler program by using JavaCompiler API.