Just a suggestion:
The Java compiler has a public API. It is also integrated with the Java Scripting Engine API. You can read here:
Little Tutorials about it. Maybe somehow scripting the compiler can help you achieve the things you want, at least a start. If you want to learn more about scripting a Java application you can read my latest tutorial at:
Script Thy Java App | Little Tutorials
In running this kind of application online you have to consider the security implications.
Good luck