So you either want to learn javac or Java Compiler API?
If you want CLI compilation look at javac (Linux | windows).
Alternatively for API, then programmatic use of Java's compiler API will definitely require more that one line, this will get you the compiler:
JavaCompiler
compiler =
ToolProvider
.getSystemJavaCompiler()
;
Then you'll still need to load classes, write out byte code, and possibly package as a JAR.
You should use StandardJavaFileManager
as you've probably many classes to manage, there's an example in the top of the JavaCompiler javadoc, but search for StandardJavaFileManager+JavaCompiler+example to find clearer examples like this blog post.