Jess Information

Jess Home
Jess 7 Features
Download Now!

Documentation
FAQ
Manual
Getting Help
Jess Wiki

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

JESS ®, the Rule Engine for the JavaTM Platform

The Jess FAQ

© 2008 Sandia National Laboratories
You can obtain the most recent version of this document at http://www.jessrules.com/jess/FAQ.shtml
Mon Nov 25 10:06:06 PST 2013

1. What is Jess?
2. Who wrote Jess?
3. What are the licensing issues surrounding Jess?
4. What versions of Jess are there?
5. Where can I download Jess?
6. How do I know if a rule-based solution is appropriate for my problem?
7. How can I learn to program with Jess?
8. Where can I get more information about Jess?
9. How do I make Jess run forever?
10. I'm having problems compiling an older verion of Jess. Why?
11. Are there any known bugs in Jess?
12. My expert system is slow. How do I speed it up?
13. Can Jess do fuzzy logic like FuzzyCLIPS?
14. Can Jess do backwards chaining?
15. How do I loop over all the facts my rule LHS matches?
16. When I try one of the code examples in the Jess manual, I get an exception.
17. I wrote a rule with a function call on the LHS, and it never fires. Why?
18. I wrote a rule with a function call on the LHS, and it fires even when it shouldn't. Why?
19. I get a stack trace with the error message "Error during execution" or "Called method threw an exception." What's going on?
20. When I try to use Jess in my Java program, I get a stack trace that includes the method "Rete.loadScriptLib()." What's wrong?
21. Why doesn't jess.jar have a Main-Class attribute so that I can double-click it and launch Jess?
22. When is the next version of Jess coming out?
23. I have the JessDE installed. I upgraded some other Eclipse plugins and installed some new ones using the automatic update feature, and now the JessDE has completely disappeared! I don't see any "clp" file icons, no "clp" file editor, nothing. What's going on?
1. What is Jess?
Jess is a tool for building a type of intelligent software called Expert Systems. An Expert System is a set of rules that can be repeatedly applied to a collection of facts about the world. Rules that apply are fired, or executed. Jess uses a special algorithm called Rete to match the rules to the facts. Rete makes Jess much faster than a simple set of cascading if.. then statements in a loop. Jess was originally conceived as a Java clone of CLIPS, but nowadays has many features that differentiate it from its parent. You can learn more about expert systems from the Expert Systems FAQ (which hasn't been updated in quite a while.)
2. Who wrote Jess?
Jess was written by Ernest Friedman-Hill at Sandia National Laboratories as part of an internal research project. The first version of Jess was written in late 1995, when Java was very, very new. Jess has evolved considerably since then! A large number of Jess users have contributed code, suggestions, and patches; many of them are thanked by name in the Jess Manual.
3. What are the licensing issues surrounding Jess?
Jess is and will always be available at no cost for academic use worldwide, with an appropriate license. Commercial users can purchase a Jess license by contacting Sandia's Technology Transfer office (email: ip@sandia.gov.) The licensing fees are negotiable and generally quite reasonable. You can also purchase an inexpensive "Home Office" license. Jess is not licensed under the GPL, the LPGL, the BSD license, or any other free software or open source license. Redistribution of the Jess source code under any free software or open source license is prohibited.
4. What versions of Jess are there?
Often there is one "released" version and one "test" version available for download at any one time. As of this writing, version 7.1p2 is the stable version. Jess 8 is currently the test version. Jess 6.1, which works with JDK 1.2, Jess 5.2, an older release that works with JDK 1.1, and Jess version 4.5, an even older release that is compatible with JDK 1.0.2, are also available, but are not supported. You are always encouraged to download and try out the test version, if available.
5. Where can I download Jess?
From the official Jess home page at http://www.jessrules.com/. There are no authorized mirror sites.
6. How do I know if a rule-based solution is appropriate for my problem?
An essay by George Rudolph attempts to answer this question.
7. How can I learn to program with Jess?
This essay by Jason Morris is a great place to start.
8. Where can I get more information about Jess?
From the official Jess home page at http://www.jessrules.com/jess. To work with Jess, it helps to know Java, although it's not an absolute requirement.
9. How do I make Jess run forever?
The (run) function will stop running as soon as there are no activated rules. This is not appropriate for some applications; for example, an intelligent agent probably should keep running at all times. Jess 5 introduces the (run-until-halt) function which will run until (halt) is called. If there are no rules to fire, run-until-halt suspends the calling Thread until new rules are activated.

To keep the (run) command from ever returning in earlier versions of Jess, you merely need to write a rule that will always be activated. Mine generally looks like this:
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; This fact will be used to sleep when idle

  (deffacts idle-fact
    (idle))

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; This rule will always be on the agenda! Make the salience
  ;; lower than any other rule.

  (defrule sleep-if-bored
    (declare (salience -100))
    ?idle <- (idle)
      =>
    (retract ?idle)
    (call java.lang.Thread sleep 100)
    (assert (idle)))
This "idle rule" technique is useful in other contexts, too -- for instance, as a way of updating a "timestamp" fact.
10. I'm having problems compiling an older verion of Jess. Why?
The following are all the known issues with compiling older versions of Jess. Please let me know of any others.
  • Warnings about keyword assert in JDK 1.4. Jess's Java code has included an important public member function named assert() since the first version. JDK 1.4 introduces a new Java keyword, assert. These names conflict, so there is a warning. The JDK has a compatibility mode, though, and it compiles code that uses this function name just fine -- it just complains a little. Jess's assert() method is deprecated in Jess 6.1 and has been removed in Jess 7.
  • Errors mentioning keyword assert in JDK 1.5. The warnings given by JDK 1.4 turn into errors in JDK 1.5. To compile Jess 6.1 and earlier with JDK 1.5, you need to use the "-source 1.3" switch to javac. If you're building with the supplied Makefile, just add "-source 1.3" to the JAVAFLAGS line.
  • Jess 5 and JBuilder. Apparently JBuilder has problems with some of the nested classes in the jess.RU class in Jess 5 and up. Here is a suggested procedure from Professor Louis Barton:
    1. Build the project.
    2. The compiler will issue an error in RU.java; re-build RU.java only.
    3. Then run the applet.
    4. If the project source code subsequently changes, do a make only.

11. Are there any known bugs in Jess?
Delays with multiple jess.Rete objects in Jess 5.2. In Jess 5.2, all Rete objects inadvertently share a single String object for use as the activation semaphore; this causes interference between multiple engines. To fix this, change line 713 in jess/Rete.java to look like this:
      private Object m_activationSemaphore = new String("ACTIVATION LOCK");
Also have a look at the release notes in the development version of Jess for news about any problems being addressed in new releases.
12. My expert system is slow. How do I speed it up?
The performance of a Rete-based system depends not so much on the number of rules and facts but on the number of partial matches generated by the rules. The Jess manual mentions this briefly, but there is a much better treatment in the Giarratano and Riley book (also mentioned in the Jess Manual.) The classic example of writing efficient rules looks like this: this rule
(defrule match-1
  (item ?x)
  (item ?y)
  (item ?z)
  (item ?w)
  (find-match ?x ?y ?z ?w)
  => )
is HORRIBLE, because it must form all possible permutations of 'item' facts before finding the one permutation that matches the 'find-match' fact. If there are 10 'item' facts, this is 10x10x10x10 = 10,000 partial matches are sent to the last join node - a lot of bookkeeping! If you rewrite the rule like this:
(defrule match-2
  (find-match ?x ?y ?z ?w)
  (item ?x)
  (item ?y)
  (item ?z)
  (item ?w)
  => )
Then there is precisely one partial match sent to the last join node - actually only one is sent to each join node. Whereas the first rule might take several minutes to reset on a slow machine, the second rule resets instantaneously.

The jess (view) command can be used to explore the efficiency of your rules.
13. Can Jess do fuzzy logic like FuzzyCLIPS?
Bob Orchard, the creator of FuzzyCLIPS, has developed a Fuzzy Java Toolkit and used it to create a fuzzy extension for Jess. His FuzzyJess extension works with Jess 5.0 and later and is available at http://ai.iit.nrc.ca/IR_public/fuzzy/fuzzyJToolkit.html .)
14. Can Jess do backwards chaining?
Jess version 5 and up have built-in support for efficient backwards chaining. See the Jess manual for details. Jess's backward chaining is a bit unorthodox, so you may need to experiment to get used to it.
15. How do I loop over all the facts my rule LHS matches?
You're still thinking procedurally; that's not how you do things in rule-based languages. Instead of trying to write this using a loop in a rule that fires once, simply write a rule which matches one fact on the LHS and processes that fact on the RHS. When you run your program, the rule will fire once for each matching fact.
16. When I try one of the code examples in the Jess manual, I get an exception.
The Jess manual is automatically tested, just like the rest of Jess. Every code example in the manual is automatically executed and the results compared against the manual for 100% accuracy before each Jess release. If something you read in the manual is wrong, most of the time what's happening is that you're using the wrong version of the manual for the software you have.
17. I wrote a rule with a function call on the LHS, and it never fires. Why?
The things on the left-hand side (LHS) of a rule aren't function calls, they're patterns to be matched. So if you write the following rule:
(defrule rule-1
  (number ?x)
  (< ?x 3)
  =>
  (printout t ?x " is less than 3." crlf))
it won't work the way you expect. Instead of comparing ?x to 3, the line (< ?x 3) is a pattern that matches facts like (< 2 3) and (< 27 3). Since you probably don't have any such facts, this rule will never fire. If you want to write a pattern that consists solely of a function call, use the test CE.
(defrule rule-2
  (number ?x)
  (test (< ?x 3))
  =>
  (printout t ?x " is less than 3." crlf))

18. I wrote a rule with a function call on the LHS, and it fires even when it shouldn't. Why?
See the previous question. You've probably written a function call surrounded by a not conditional element:
(defrule rule-3
  (number ?x)
  (not (< ?x 3))
  =>
  (printout t ?x " is not less than 3." crlf))
the second pattern is true whenever there are no facts that look like (< 39 3). Since you probably don't have any such facts, this condition will always be met, and the rule will always fire. You can rewrite this with a test conditional element:
(defrule rule-4
  (number ?x)
  (test (not (< ?x 3)))
  =>
  (printout t ?x " is not less than 3." crlf))

19. I get a stack trace with the error message "Error during execution" or "Called method threw an exception." What's going on?
While Jess was running, it called a Java method that threw an exception other than JessException. Because Jess's methods are declared to only throw JessException, Jess had to wrap the foreign exception inside a JessException and rethrow it. Thus the exception you're looking at is just a wrapper for the real problem exception.

The JessException class has a method getCause which returns non-null when a particular JessException is a wrapper for a foreign exception. JessException.getCause() will return the real exception that was thrown. Your JessException handlers should always check getCause(); if your handler simply displays a thrown exception, then it should display the return value of getCause(), too.
20. When I try to use Jess in my Java program, I get a stack trace that includes the method "Rete.loadScriptLib()." What's wrong?
There's a file "scriptlib.clp" inside the "jess" package -- i.e., it's in the same directory as Rete.class . If you're compiling and deploying your own copy of Jess from source, then you must include this file along with the .class files when you deploy Jess. It must remain in the "jess" directory.
21. Why doesn't jess.jar have a Main-Class attribute so that I can double-click it and launch Jess?
This is deliberate. If you launch Jess that way, the Java classloader will not load any classes from outside jess.jar; Jess will be a closed system. This doesn't happen if you run it the way we suggest.
22. When is the next version of Jess coming out?
Jess 7.1p2 was released on November 5th, 2008. Work on the next version of Jess, which will support Java 5 features, has begun.
23. I have the JessDE installed. I upgraded some other Eclipse plugins and installed some new ones using the automatic update feature, and now the JessDE has completely disappeared! I don't see any "clp" file icons, no "clp" file editor, nothing. What's going on?
Some users have reported that updating other Eclipse features can cause the JessDE plugins to be disabled. We don't know why this happens, but we know what to do: open the dialog box at Help > Software Updates > Manage Configuration in Eclipse, and enable the JessDE feature.

Feedback? ejfried@sandia.gov