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.1 is compatible with all released versions of Java starting with JDK 1.4, including JDK 1.6, 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 Jess71p2/. 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:\Jess71p2> bin\jess.bat Jess, the Rule Engine for the Java Platform Copyright (C) 2008 Sandia Corporation Jess Version 7.1p1 8/6/2008 Jess>
Jess> (+ 2 2)
Jess> (batch "examples/jess/sticks.clp") Who moves first (Computer: c Human: h)?
C:\Jess71p2> bin\jess.bat examples\jess\sticks.clp Jess, the Rule Engine for the Java Platform Copyright (C) 2008 Sandia Corporation Jess Version 7.1p1 8/6/2008 Who moves first (Computer: c Human: h)?
126.96.36.199. Command-line editing
When working at the Jess command line, it's convenient to be able to edit and reinvoke previous commands. The Jess library doesn't support this directly, but the excellent open-source product JLine can add this capability to any command-line Java program, Jess included. JLine works great with the Jess prompt and I strongly recommend it.
188.8.131.52. Graphical consoleThe class jess.Console is a simple graphical version of the Jess command-line interface. You type into a text field at the bottom of the window, and output appears in a scrolling window above. Type
C:\Jess71p2> 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:\Jess71p2> bin\jess examples\jess\fullmab.clp
Jess> (reset) (run)