Compile Java Files At Runtime

Java 6 has a new Compiler API, as a result of JSR 199, which requests for a standard way to compile java source files. Although I use a lot of Java, I don't get to use some of the Java API's, as they are not required for the business functionality that I usually code. So, I was looking around for some new ideas or code to try and thought of working on a simple Java IDE and got to work on JavaCompiler class from package of Java 6. Here's a naive example, that shows how to compile a Java source file at runtime: