javatools.java
Class Javac

java.lang.Object
  |
  +--javatools.java.Javac

public class Javac
extends java.lang.Object

Compiles a Java class and returns the byte codes. Requires the tools.jar archive from the Sun jdk.


Nested Class Summary
 class Javac.CompiledClass
           
 
Field Summary
(package private)  java.util.Collection classes
           
(package private)  java.lang.String classPath
           
(package private)  java.lang.String compilerOutput
           
(package private)  boolean success
           
 
Constructor Summary
Javac()
           
 
Method Summary
 boolean compile(java.lang.String fullname, java.lang.String sourcecode)
          Compile the given Java class.
 java.util.Collection getClasses()
          The byte code of the classes we just compiled.
 java.lang.String getClassPath()
           
 java.lang.String getCompilerOutput()
          The output and error messages from the compiler.
 boolean getSuccess()
          Was the compilation successful? You need to call compile first.
 void setClassPath(java.lang.String classPath)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classes

java.util.Collection classes

compilerOutput

java.lang.String compilerOutput

success

boolean success

classPath

java.lang.String classPath
Constructor Detail

Javac

public Javac()
Method Detail

setClassPath

public void setClassPath(java.lang.String classPath)

getClassPath

public java.lang.String getClassPath()

getClasses

public java.util.Collection getClasses()
The byte code of the classes we just compiled.

Returns:
a Collection of java.Javac.Class objects.

getSuccess

public boolean getSuccess()
Was the compilation successful? You need to call compile first.

Returns:
The success value

getCompilerOutput

public java.lang.String getCompilerOutput()
The output and error messages from the compiler.

Returns:
The compilerOutput value

compile

public boolean compile(java.lang.String fullname,
                       java.lang.String sourcecode)
                throws java.io.IOException
Compile the given Java class. synchronized to improve our chances we won't stuff up our reassignment of System.out and .err.

Parameters:
fullname - the full Java name of the class contained in sourcecode
sourcecode - the Java source code of the class fullname
Returns:
whether compilation was successful
Throws:
java.io.IOException - Description of Exception