Class Compiler


public class Compiler
extends java.lang.Object

A simplified substitute for the javac tool. Usage:

 java net.janino.Compiler \
           [ -d destination-dir ] \
           [ -sourcepath dirlist ] \
           [ -classpath dirlist ] \
           [ -extdirs dirlist ] \
           [ -bootclasspath dirlist ] \
           [ -encoding encoding ] \
           [ -verbose ] \
           source-file ...
 java net.janino.Compiler -help

Inner Class Summary
static class Compiler.NoClassLoader
          A ClassLoader that never loads any class.
Constructor Summary
Compiler([] optionalSourcePath,[] classPath,[] optionalExtDirs,[] optionalBootClassPath, optionalDestinationDirectory, java.lang.String optionalCharacterEncoding, boolean verbose, int debuggingInformation)
          Initialize a JavaTM compiler with the given parameters.
Method Summary
 void compile([] sourceFiles)
          Compiles a set of JavaTM compilation units (a.k.a.
static getClassFile(java.lang.String className, sourceFile, optionalDestinationDirectory)
          Construct the name of a file that could store the byte code of the class with the given name.
static void main(java.lang.String[] args)
          Command line interface.
static[] parsePath(java.lang.String s)
          Break a given string up by a "separator" string.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public Compiler([] optionalSourcePath,
      [] classPath,
      [] optionalExtDirs,
      [] optionalBootClassPath,
                java.lang.String optionalCharacterEncoding,
                boolean verbose,
                int debuggingInformation)
Initialize a JavaTM compiler with the given parameters.

Classes are searched in the following order:

optionalSourcePath -  
classPath -  
optionalExtDirs -  
optionalBootClassPath -  
optionalDestinationDirectory -  
optionalCharacterEncoding -  
verbose -  
Method Detail


public static void main(java.lang.String[] args)
Command line interface.


public void compile([] sourceFiles)
             throws Scanner.ScanException,
Compiles a set of JavaTM compilation units (a.k.a. "source files") into a set of "class files". Additional source files are parsed and compiled on demand through the "source path" set of directories.

For example, if the source path comprises the directories "A/B" and "../C", then the source file for class "com.acme.Main" is searched in

Notice that it does make a difference whether you pass multiple source files to compile(File[]) or if you invoke compile(File[]) multiply: In the former case, the source files may contain arbitrary references among each other (even circular ones). In the latter case, only the source files on the source path may contain circular references, not the sourceFileNames.
sourceFileNames - Source file path names


public static[] parsePath(java.lang.String s)
Break a given string up by a "separator" string. Empty components are ignored.


A, B, C
(Empty string)
(Zero components)


public static getClassFile(java.lang.String className,
Construct the name of a file that could store the byte code of the class with the given name.

If optionalDestinationDirectory is non-null, the returned path is the optionalDestinationDirectory plus the package of the class (with dots replaced with file separators) plus the class name plus ".class". Example: "destdir/pkg1/pkg2/Outer$Inner.class"

If optionalDestinationDirectory is null, the returned path is the directory of the sourceFile plus the class name plus ".class". Example: "srcdir/Outer$Inner.class"

className - E.g. "pkg1.pkg2.Outer$Inner"
sourceFile - E.g. "srcdir/"
optionalDestinationDirectory - E.g. "destdir"