Jess Information

Jess Home
Jess 7 Features
Download Now!

Getting Help
Jess Wiki

More information Related Web Sites
User Contributions
JSR94 Info
About This Site

JESS ®, the Rule Engine for the JavaTM Platform

JSR94 Information

The information here applies to the JSR94 reference implementation, which was included in the JSR94 downloads available from It does not apply to the new JSR94 driver that ships with Jess 7. You are strongly encouraged to try out the new driver (in package gov.sandia.jess.jsr94) and avoid using the old reference implementation driver (in package

The information below is missing from the JSR94 Public Review package. It describes how to use the JSR94 Reference Implementation. The JSR94 Public Review Package 1.0 is available at

The RI is a wrapper for the Jess rule engine. You need to use Jess 6.1a3 or later with this RI. Note that some versions of the JSR94 package may have accidentally been shipped with a long-since-expired trial distribution of Jess. If your JSR94 software refuses to run, you may need to download your own copy of Jess and replace the jess.jar file in the JSR94 distribution with a new one. In particular, the file jsr94-j2ee.war contains a copy of jess.jar, and jsr94-j2ee.ear contains a copy of the WAR file, so if you want to run the J2EE demo, you'll need to unpack these two files and replace the expired jess.jar. Please don't blame me for this -- I had nothing to do with packaging the JSR94 distribution.

Jess 6, which was current when the RI was written, didn't have a native XML file format, and as Jess doesn't precisely follow the rule engine model presented by the JSR 94 API, you'll need a short explanation to be able to write rules that work with this implementation. Before this document will make sense, you'll need to understand Jess. Jess comes with substantial documentation of its own.

When you call RuleSession.addObject to add an object to working memory, this implementation interprets the call as a Jess definstance call. Normally, when you call definstance in Jess, you specify a defclass name. This reference implementation automatically uses a static defclass formed from the class of the object, whose name is the full name of the objects's class. Therefore the call RuleSession.addObject("Hello") is interpreted as the sequence

   Rete engine = ...
   engine.defclass("java.lang.String", "java.lang.String", null);
   engine.definstance("java.lang.String", "Hello", false);
Therefore, all the rules you write will use the actual Java class names to match objects. The added object will be in the OBJECT slot of the corresponding fact, as always. Here's an example of a complete rule file containing a single rule that matches the String object "Hello":
<?xml version="1.0" encoding="UTF-8"?>

  <name>rule set</name>
  <description>some rules</description>
    ;; Any normal Jess code can go here.
    (defclass java.lang.String java.lang.String nil)
    (defrule test1
      (java.lang.String (OBJECT ?x&amp;:(?x equals "(Hello)")))
      (printout t "Goodbye." crlf))
Note that, even though adding an object creates the appropriate defclass, they must be defined before any rules that use them. Therefore, it's prudent to include any defclasses you expect to need in your rule file. Also note that XML special characters like &, <, and > must be escaped.