edu.uci.eecs.doc.cascade.util
Class Compiler

java.lang.Object
  extended by edu.uci.eecs.doc.cascade.util.Compiler

public class Compiler
extends Object

Invokes a given Java compiler on a given source file. Note that the Java Compiler API is not used and the compiler is instead executed directly. The reason is that configuring the Compiler API to use a custom compiler is extremely difficult.

Author:
Trevor Harmon

Constructor Summary
Compiler(String compiler, String classPath, String sourcePath, String outputDir)
          Creates a new Compiler object.
 
Method Summary
 Class compile(String sourceFile)
          Runs the compiler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Compiler

public Compiler(String compiler,
                String classPath,
                String sourcePath,
                String outputDir)
         throws CompilerException
Creates a new Compiler object.

Parameters:
compiler - location of the compiler executable (e.g., /usr/bin/javac)
classPath - the class path to pass to the compiler, with each directory separated by File.pathSeparator
sourcePath - the source path to pass to the compiler, with each directory separated by File.pathSeparator
outputDir - the directory in which to place compiled classes
Throws:
CompilerException - if the output directory or any element of the class path or source path do not exist
Method Detail

compile

public Class compile(String sourceFile)
              throws CompilerException
Runs the compiler.

Parameters:
sourceFile - a Java source file
Returns:
a handle to the class file that the compiler created
Throws:
CompilerException - if the compiler task failed or if a handle to the compiled class could not be created