Utility class to compile java source code in memory
Clone or download
Latest commit d84c404 Nov 13, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
src merged with turpid-monkey/master with some minor refactoring Sep 27, 2017
.gitignore gitignore Sep 24, 2017
.travis.yml code coverage with codecov Oct 10, 2017
LICENSE Create LICENSE Sep 9, 2016
README.md Update README.md Nov 13, 2017
pom.xml code coverage with codecov Oct 10, 2017


Update 09/22/2017: I've been silent for long time (I'm into Golang lately hence putting Java aside) despite the fact that there are lots of interests to make this mini tool better. I'll kick off my effort to improve this tool from now on by reviewing outstanding issues and PRs

InMemoryJavaCompiler Build Status codecov FOSSA Status

Samples with utility classes to compile java source code in memory

After taking huge effort to look for example on the internet and found nothing work. I decided to create a very simple version.

Note: Please make sure you use JDK in your runtime


StringBuilder sourceCode = new StringBuilder();
sourceCode.append("package org.mdkt;\n");
sourceCode.append("public class HelloClass {\n");
sourceCode.append("   public String hello() { return \"hello\"; }");

Class<?> helloClass = InMemoryJavaCompiler.newInstance().compile("org.mdkt.HelloClass", sourceCode.toString());

If you are looking for more examples, please look at unit tests in the src/test/java folder

Artifact is pushed to Sonatype OSS Releases Repository


Maven dependency:



FOSSA Status