Create a Java compiler. When dest is specified, the compile code are written to that place. dest can be ZipOutputStream, File, or String.
c = javaCompiler()
c = javaCompiler("classes")
zout = openZip("test.jar", "w")
c = javaCompiler(zout)
c.compile("Test.java")
zout.close()
Register a pair of the specified file name and the content.
c.addJavaFile("Hello.java", readText("Hello.java"))
c.addJavaFile(walkDirectory("../src")[function (f) f.name.endsWith(".java")])
Compile the Java source code. javaSourceFiles can be String, java.io.File, or an array/Collection/Generator of those types.
'compile(javaSourceFiles)' is equivalent to 'addJavafile(javaSourceFiles); compile()'.
'compile(fileName, content)' is equivalent to 'addJavafile(fileName, content); compile()'.
c.compile("Hello.java")
c.compile(walkDirectory("src")[function (f) f.name.endsWith(".java")])
Set a character encoding for subsequent compilation.
c.setEncoding("utf-8")
Set the source path for subsequent compilation.
c.setSourcePath("src")
Set the class path for subsequent compilation.
c.setClassPath("mylib.jar")
c.setClassPath(walkDirectory("lib")[function (f) f.name.endsWith(".jar")])
Get the class loader from which the compiled code are loaded.
c.getClassLoader().loadClass("MyClass")
getContext().setClassLoader(c.getClassLoader()) MyClass