net.janino
Class Compiler

java.lang.Object
  |
  +--net.janino.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(java.io.File[] optionalSourcePath, java.io.File[] classPath, java.io.File[] optionalExtDirs, java.io.File[] optionalBootClassPath, java.io.File optionalDestinationDirectory, java.lang.String optionalCharacterEncoding, boolean verbose, int debuggingInformation)
          Initialize a JavaTM compiler with the given parameters.
 
Method Summary
 void compile(java.io.File[] sourceFiles)
          Compiles a set of JavaTM compilation units (a.k.a.
static java.io.File getClassFile(java.lang.String className, java.io.File sourceFile, java.io.File 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 java.io.File[] 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

Compiler

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

Classes are searched in the following order:

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

main

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

compile

public void compile(java.io.File[] sourceFiles)
             throws Scanner.ScanException,
                    Parser.ParseException,
                    Java.CompileException,
                    java.io.IOException
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

A/B/com/acme/Main.java
../C/com/acme/Main.java
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.
Parameters:
sourceFileNames - Source file path names

parsePath

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

Examples:

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

getClassFile

public static java.io.File getClassFile(java.lang.String className,
                                        java.io.File sourceFile,
                                        java.io.File optionalDestinationDirectory)
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"

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