2. The JessDE Developer's Environment

Jess 7 includes an Eclipse-based development environment. There is an editor, a debugger, and a Rete network viewer. More components (a rule browser and other tools) will be included in future releases.

2.1. Installing the JessDE

The Jess Developer's Environment (JessDE) is supplied as a set of plugins for the popular open-source IDE Eclipse; in particular, these are plugins for Eclipse version 3.1 or later.

To install the JessDE, simply exit Eclipse, unzip all the files from Jess70b7/eclipse into the top-level Eclipse 3 installation directory, and then restart Eclipse.

IMPORTANT! If you're updating from a previous version of the JessDE, you must launch Eclipse with the "-clean" command-line switch to force it to update the information it caches regarding the JessDE plugins. If you don't do this, many of the JessDE's options will be disabled. You only need to do this once after the installation.

Note that the JessDE works only with the full "Eclipse SDK" -- the smaller "Platform Runtime Binary" is insufficient.

The JessDE editor creates problem markers to point out syntax errors and warnings in your Jess documents. You most likely want to have these markers show up in the Eclipse "Problems" view, although they may not show up by default. After installing the JessDE and restarting Eclipse, in the Problems view, click on the "Filters" icon in the title bar, and check the box labelled "Jess Problem". Your Problems view should now display Jess errors and warnings.

2.2. Using the JessDE

2.2.1. The Jess language editor

The JessDE editor can edit ".clp" files. By default, any file you create with the extension "clp" will be opened using the JessDE editor. There's no separate Jess perspective, or Jess project type; we expect that most people will use the JessDE tools to write the Jess components of a hybrid Jess/Java application, and so the tools expect to be used on files in a Java project. The JessDE uses your Java project's class path to resolve Java class names used in Jess language code -- i.e., in a call to the defclass function.

You should add jess.jar to the "Java Build Path" of any project that contains Jess source code. This is necessary to allow Eclipse to run or debug your program. You can use the jess.jar that is included in the gov.sandia.jess plug-in.

The editor has all the features you'd expect from a modern programmer's editor.

Syntax coloring you can customize.
You can change the default colors using the "Jess Editor" tab of the Eclipse global preferences dialog.
Content assistant supplies deftemplate, slot and function names.
You can invoke Eclipse's "Content Assist" feature in many different places within the JessDE editor; JessDE will make it much easier to enter Jess code. Press Alt-'/' while typing to produce a list of choices.
"Quick fix" assistant can repair code automatically
This feature is bound to Ctrl-1 by default. Quick fix currently knows how to define undefined deftemplates, and add new slots to existing deftemplates (if they're defined in the same file.) More to come!
Real-time error checking with markers and error highlighting
Errors and warnings are highlighted as you type
Automatic code formatting
Code is indented as you type. You can also choose "Format" from the "Source" menu to format an entire buffer.
Fast navigation using outline view
The Eclipse outline view lists all the constructs defined in a buffer; you can click on any one of them to quickly navigate to it.
Parenthesis matching and auto-insertion
When you type a '(' or '"' character, JessDE insert the matching character as well. When your cursor is next to a parenthesis, JessDE shows you the matching parenthesis.
Online help for Jess functions and constructs via "hovers"
You have quick access to the Jess manual description of every function and construct type.
Help hovers for deftemplates and deffunctions
If you hold your mouse over the name of a deftemplate or deffunction, anywhere in the code, JessDE will show a "tooltip" containing information about that template or function.
Run and Debug commands for Jess programs
You can run or debug a Jess program using the normal Eclipse "Run..." menu. Note that for a project to run properly, jess.jar has to be in the project's build path, either directly, or via a dependency on the gov.sandia.jess plug-in.

2.2.2. Dependencies among files

Sometimes one *.clp file depends on code in some other *.clp file having been read first; for example, rules.clp might need the definitions in templates.clp. Without these definitions, rules.clp will appear to have syntax errors. To deal with this, you can use the require* function. "require*" lets you explicitly declare these dependencies.

If a file rules.clp depends on Jess commands being executed from Java, you can deal with this by creating a special file just for this purpose (you might call it ruledepends.clp That special file can contain whatever declarations are needed to make rule.clp parse properly in the editor. If you add "(require* ruledepends)" to rules.clp, then this extra file will be parsed only if it's present, as it will be during development. When you deploy the code, you can simply not deploy ruledepends.clp, and allow rules.clp to get its declarations from Java code.

The "require" mechanism replaces the "Source dependencies" property sheet from earlier versions of JessDE, which is no longer supported.

2.2.3. The Rete Network view

You can instantly see a graphical representation of the Rete network derived from any rule using the JessDE's "Rete Network View". When this view is open (you can open it using the "Windows | View | Other..." dialog in Eclipse) it will display the Rete network for the rule that the editor caret is in. You can use this to see, in real time, how modifying a rule changes the Rete network. The graph layout is far superior to that you get from the Jess "view" command -- there are no overlapping or crossing lines, and the height of each "column" can vary.

To use the Rete Network View, you'll need to have the Eclipse Graph Editing Framework (GEF) installed. You can get the GEF from the Eclipse project page here.

2.2.4. The Jess debugger

The JessDE debugger lets you debug a Jess program defined in a .clp file. It has all the features you'd expect from a graphical debugger: you can suspend and resume a program, or step through it. When the program is stopped, the contents of the execution stack are displayed, and you can examine the variables defined in each stack frame. Selecting a stack frame also navigates to the source code being executed. You can also set (or clear) breakpoints in any .clp file by right-clicking in the ruler on the left-hand edge of the editor window. Breakpoints can be set only on functions (either built-in or user defined), so you can't break on a defrule or deftemplate construct. You can, however, break on a function call on the left or right-hand side of a rule.