Skip to: Site menu | Main content


Java Rules Engine

Tutorials and Examples Print

Tutorials and Examples for New Users

If you're just getting started with Drools and you'd like to see some working examples or need information about writing Java-based DRL files, then this is a good place to start. We've collected our most basic introductory documentation for new users and anyone evaluating Drools. If you have an idea for documentation that you'd like covered, please let us know.

Getting Examples Running

Running examples from CVS via Maven:

Running examples from CVS via Ant:

Running examples using precompiled jars from the command line:

Examples Alphabetically

Also shown are the maven/ant goals for the examples

Tutorials and Examples by Category

Conflict Resolution

Conflict Resolution is used to prioritize activations within the Agenda. This is normally done through the use of Salience values.


Recursion is where one rule can assert, modify and retract facts causing itself to be run.

Application Data

Application Data is used to introduce information without having to assert it into the Working Memory.

Event Model

An Event Model is implemented to allow listeners to be executed when certain events occur; assertObject, modifyObject and retractObject events and also fire events just before and just after the execution of consequence blocks.

Temporal Rules

A Duration can given to specify the length of time a rule must be true before it fires:

JSR-94: Java Rule Engine API

Drools is a JSR-94 compliant rule engine.

For instructions on how to run Drools under the JSR-94 Technology Compatibility Kit, please see:

Large # of Rules / Large # of Facts

The Prime Factors example was created to demonstrate Drools' ability to work with a large number of rules and a large number of facts. While the example is coded to work with 170 rules and 1000 facts, the example code can easily be extended to work with any arbitrarily large number of rules and/or facts.

GUI and Swing

While drools itself does not provide a GUI API it does provide the ability to link a GUI with a rules engine via Application Data and make a reference available to the JFrame to the Working Memory.

GUI is demonstrated in the following examples: