Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Packages

Download the latest version of Janino:

  • Janino distribution (signed JAR file, JAVADOC documentation files and complete source code)

...

distribution of Janino from the download page.

Anchor
installation
installation

Installation

Unzip the ZIP distribution file you have downloaded:

...

You will find the Janino JAR filefiles, the JAVADOC documentation, and the complete source code .

To compile the demo programs, run

Code Block

$ mkdir classes
$ javac -classpath lib/janino.jar -sourcepath src -d classes \
> src/org/codehaus/janino/samples/ExpressionDemo.java \
> src/org/codehaus/janino/samples/ScriptDemo.java \
> src/org/codehaus/janino/samples/ClassBodyDemo.java

To learn how to use the demo programs, run:

Code Block

$ java -classpath lib/janino.jar:classes org.codehaus.janino.samples.ExpressionDemo -help
$ java -classpath lib/janino.jar:classes org.codehaus.janino.samples.ScriptDemo -help
$ java -classpath lib/janino.jar:classes org.codehaus.janino.samples.ClassBodyDemo -help

Notice: On MS Windows, the classpath separator is ";", not ":".

To compile the source code:

Code Block

$ mkdir classes
$ javac -sourcepath src -d classes src/org/codehaus/janino/Compiler.java

You will find the Janino class file in the classes subdirectory.

To generate the JAR file, run:

Code Block

$ jar cf lib/janino.jar -C classes org/codehaus/janino

To generate the JAVADOC documentation, run:

Code Block

$ mkdir javadoc
$ javadoc -splitindex -package -doctitle "Janino" \
> -windowtitle "Janino" -overview src/overview.html -sourcepath src \
> -classpath classes -d javadoc org.codehaus.janino org.codehaus.janino.samples

You will find the JAVADOC documentation in the javadoc subdirectory.

ZIP files, the text of the BSD license, and a README file.

Put "commons-compiler.jar" and "janino.jar" on your class path.

If you're using an IDE like ECLIPSE, you can optionally have "commons-compiler-src.zip" as the source attachment of "commons-compiler.jar", and "janino-src.zip" as the source attachment of "janino.jar". That'll get you tooltip JAVADOC and source level debugging into the JANINO libraries.

Use one of the features, e.g. the "expression evaluator", in your program:

Code Block

    import org.codehaus.janino.*;

    ExpressionEvaluator ee = new ExpressionEvaluator();
    ee.cook("3 + 4");
    System.out.println(ee.evaluate(null));

Compile, run, ... be happy!

Examples

The ShippingCost class demonstrates how easy it is to use Janino as an expression evaluator.

...