type safe templating


To make use of Jamon:

Example - Quick Start Mini-Tutorial

The source files mentioned in this tutorial are available individually where first referenced, or bundled in a zip file.
NOTE: If you have a Java Runtime (JRE) installed in addition to a Software Development Kit (SDK), be sure that the binaries (i.e. java, javac, etc) of the SDK come first in your PATH.
  1. Create a Jamon template QsTemp.jamon:
      java.util.Date date;
      String [] s;
    Hello, world on <% date %>.
    The arguments are:
    <%java int l = s.length; %>
    <%for int i = 0; i < l; ++i %>
    <% s[i] %>
  2. Create a java file JamonQs.java:
    import java.io.OutputStreamWriter;
    import java.io.IOException;
    import java.util.Date;
    public class JamonQs {
      public static void main(String[] argv) throws IOException {
        QsTemp template = new QsTemp();
        template.render(new OutputStreamWriter(System.out), new Date(0),argv);
  3. Set your classpath:
    Windows C:\JAMONTMP> SET CLASSPATH=.;\path\to\jamon-runtime.jar;\path\to\jamon-api.jar;\path\to\jamon-processor.jar
    Unix (sh, bash, zsh, ksh) $ export CLASSPATH=.:/path/to/jamon-runtime.jar:/path/to/jamon-api.jar:/path/to/jamon-processor.jar
    Unix (csh, tcsh) % setenv CLASSPATH=.:/path/to/jamon-runtime.jar:/path/to/jamon-api.jar:/path/to/jamon-processor.jar
  4. Process the template:
    java org.jamon.compiler.TemplateProcessor --destDir=. QsTemp
  5. Compile everything:
    javac JamonQs.java QsTemp*.java
  6. Run it:
    java JamonQs one two three
  7. You should see:
    Hello, world on Wed Dec 31 19:00:00 EST 1969.
    The arguments are: