JCK: Java Constraint Kit

Home - Documentation - Sources - Contributors - Related Links

 

Sources

JCK source code: jack_2001_03_04.tar.gz (728K)

Directory Structure and Environment Variables

There are three main directories:

evaluator:
 The JCHR evaluator core, including the JASE core files.
compiler:
Contains the JCHR compiler, which transforms JCHR handler files into Java source files.
examples:
Several small example applications.

For compiling and running all code, some environment variables need to be set up. There are three variables used by the makefiles: JCHR_JAVA, JCHR_JAVAC and CLASSPATH. Depending on the JDK used, several variations are possible:

JDK 1.1.8, using the JDK Java Compiler:


JCHR_JAVA=/usr/lib/jdk1.1.8/bin/java
JCHR_JAVAC=/usr/lib/jdk1.1.8/bin/javac
CLASSPATH=

If the java and javac executables are in the PATH, those variables can be empty.

JDK 1.1.8, using the Jikes compiler:



JCHR_JAVA=/usr/lib/jdk1.1.8/bin/java
JCHR_JAVAC=''jikes +E +P''
CLASSPATH=/usr/lib/jdk1.1.8/lib/classes.zip

JDK 1.3, using the JDK Java Compiler:



JCHR_JAVA=/usr/lib/jdk1.3/bin/java
JCHR_JAVAC=/usr/lib/jdk1.3/bin/javac
CLASSPATH=/usr/lib/jdk1.3/jre/lib/rt.jar

If the java and javac executables are in the PATH, those variables can be empty.

JDK 1.3, using the Jikes compiler:


JCHR_JAVA=/usr/lib/jdk1.3/bin/java
JCHR_JAVAC=''jikes +E +P''
CLASSPATH=/usr/lib/jdk1.3/jre/lib/rt.jar

These settings should be placed in the .bashrc file or similar, so they don't have to be typed in each time. Of course, instead of /usr/local/jdkXX/, the correct path should be substituted.

Compiling all Sources

To build all the sources, the following steps are necessary:

  1. Build the evaluator:


    cd evaluator
    make  jar
    

    This compiles all files and builds evaluator.jar in the top-level directory.

  2. Build the compiler:


    cd compiler
    make jar
    

    This compiles all files and builds compiler.jar in the top-level directory.

  3. Build the examples:


    cd examples
    make build-all
    

    This creates all Java files from the JCHR handlers, and compile them.

  4. Now a first test can be run:


    cd examples
    make init-regress
    

    The output should look like this:


    Initializing regression tests...
    bool
    fd
    leq
    min
    nqueens
    snqueens
    primes
    fdsearch
    env
    schur
    alldiff
    

    No error messages should appear here. For each of the examples, this command creates a file `` regress.<EXAMPLE>'' containing the output from the evaluator.

Using the Examples

For all applications in the examples directory, there is one single makefile. If <APP> is the name of one example (for example, `` fd'' or `` schur'', then the following commands are available:

make SAMPLE=<APP> handler:
This creates the handler for the example.
make SAMPLE=<APP> compile:
This compiles the example (provided its handler been created before).
make SAMPLE=<APP> run:
This runs the example (provided it has been compiled before).
make SAMPLE=<APP> trace:
This runs the example (provided it has been compiled before), printing a lot of debugging information.

Additionally, there are a few commands that work on all examples in one single call:

make build-all:
Creates all handlers and compiles all Java files.
make handler-all:
Creates all handlers.
make compile-all:
Compiles all examples (the handlers have to be built first).
make init-regress:
This initializes the regression tests. It should be run when all examples work correctly, so they can be used as a reference.
make regress:
Provided that the regression tests have been initialized before, this runs all tests. It outputs a message for each example which has changed since initialization. If some change to the evaluator or example code has introduced a bug or other unwanted behaviour, this can be detected using the regression test.

E.g., these commands rebuild the Finite Domain handler and compile and run the n-Queens application:


~/jack> cd examples
~/jack/examples> make SAMPLE=fd handler compile run
Queen1 = 3
Queen2 = 1
Queen3 = 4
Queen4 = 2
Search completed successfully.



Last modified: Tue Oct 22 11:39:47 CEST 2002