> How does compiling of java code from a running java
> application work?
Probably most reliably using Runtime.exec().
> I found a class:
> com.sun.tools.apt.main.JavaCompiler
> but cannot find any documentation of how this class
> works.
For a purpose. You are not supposed to use this class. With the next JRE release or implementation, it might not exist anymore - it's not part of the standard API.