1. Getting Started
Jess is a programmer's library written in Java. Therefore, to use Jess, you'll need a Java Virtual Machine (JVM). You can get an excellent JVM for Windows, Linux, and Solaris free from Sun Microsystems. Jess 7 is compatible with all released versions of Java starting with JDK 1.4, including JDK 1.5, the latest release. Older Jess versions numbered 4.x were compatible with JDK 1.0, 5.x versions worked with JDK 1.1, and Jess 6 worked with JDK 1.2 and up.
Be sure your JVM is installed and working correctly before trying to use Jess.
To use the JessDE integrated development environment, you'll need version 3.1 or later of the Eclipse SDK from http://www.eclipse.org. Be sure that Eclipse is installed and working properly before installing the JessDE.
The Jess library serves as an interpreter for another language, which I will refer to in this document as the Jess language. The Jess language is a highly specialized form of Lisp.
I am going to assume that you, the reader, are a programmer who will be using either one or both of these languages. I will assume that all readers have at least a minimal facility with Java. You must have a Java runtime system, and you must know how to use it at least in a simple way. You should know how to use it to
- run a Java application
- deal with configuration issues like the CLASSPATH variable
- (optional) compile a collection of Java source files
If you do not have at least this passing familiarity with a Java environment, then may I suggest you purchase an introductory book on the topic. Java software for many platforms -- as well as a wealth of tutorials and documentation -- is available at no cost from http://java.sun.com.
For those readers who are going to program in the Jess language, I assume general familiarity with the principles of programming. I will describe the entire Jess language, so no familiarity with Lisp is required (although some is helpful.) Furthermore, I will attempt to describe, to the extent possible, the important concepts of rule-based systems as they apply to Jess. Again, though, I will assume that the reader has some familiarity with these concepts and more. If you are unfamiliar with rule-based systems, you may want to purchase a text on this topic as well.
Many readers will want to extend Jess' capabilities by either adding commands (written in Java) to the Jess language, or embedding the Jess library in a Java application. Others will want to use the Jess language's Java integration capabilities to call Java functions from Jess language programs. In sections of this document targeted towards these readers, I will assume moderate knowledge of Java programming. I will not teach any aspects of the Java language. The interested reader is once again referred to your local bookstore.
This document contains a bibliography wherein a number of books on all these topics are listed.
1.2. Getting ready
1.2.1. Unpacking the DistributionJess is supplied as a single .zip file which can be used on all supported platforms. This single file contains all you need to use Jess on Windows, UNIX, or the Macintosh (except for a JVM, which you must install yourself.) When Jess is unpacked, you should have a directory named Jess70b7/. Inside this directory should be the following files and subdirectories:
|README||A quick start guide.|
|LICENSE||Information about your rights regarding the use of Jess.|
|bin||A directory containing a Windows batch file (jess.bat) and a UNIX shell script (jess) that you can use to start the Jess command prompt.|
|lib||A directory containing Jess itself, as a Java archive file. Note that this is not a "clickable" archive file; you can't double-click on it to run Jess. This is deliberate. This directory also contains the JSR-94 (javax.rules) API in the file jsr94.jar.|
|docs/||This documentation. "index.html" is the entry point for the Jess manual.|
|examples/jess||A directory of small example programs in the Jess language.|
|examples/xml||A directory of small example programs in JessML, Jess's XML rule language.|
|eclipse||The JessDE, Jess's Integrated Development Environment, supplied as a set of plugins for Eclipse 3.0. See here for installation instructions.|
|src (Optional)||If this directory is present, it contains the full source for the Jess rule engine and development environment, including an Ant script for building it.|
1.2.2. Command-line InterfaceJess has an interactive command-line interface. The distribution includes two scripts that you can run to get a Jess command prompt: one for Windows, and one for UNIX. They're both in the bin/ directory. Run the one that's appropriate for your system, and you should see something like this
C:\Jess70b7> bin\jess.bat Jess, the Rule Engine for the Java Platform Copyright (C) 2006 Sandia Corporation Jess Version Jess70b7 1/17/2006 Jess>
Jess> (+ 2 2) 4
Jess> (batch "examples/jess/sticks.clp") Who moves first (Computer: c Human: h)?
C:\Jess70b7> bin\jess.bat examples\jess\sticks.clp Jess, the Rule Engine for the Java Platform Copyright (C) 2004 Sandia Corporation Jess Version Jess70b7 9/17/2004 Who moves first (Computer: c Human: h)?
C:\Jess70b7> java -classpath lib\jess.jar jess.Console
1.2.3. Java Programming with JessTo use Jess as a library from your Java programs, the file jess.jar (in the lib directory) must either be on your class path, be installed as a standard extension, or your development tools must be set up to recognize it. The details of doing these tasks are system and environment dependent, but setting the class path usually involves modifying an environment variable, and installing a standard extension simply means copying jess.jar into your $(JAVA_HOME)/jre/lib/ext directory. Refer to the Java documentation or an introductory Java text for details.
1.2.4. Jess Example ProgramsThere are some simple example programs (in the examples/jess and examples/xml directories) that you can use to test that you have installed Jess properly. These include fullmab.clp, zebra.clp, and wordgame.clp. fullmab.clp is a version of the classic Monkey and Bananas problem. To run it yourself from the command line, just type:
C:\Jess70b7> bin\jess examples\jess\fullmab.clp