The Drools project wizard can be used to set up an executable project that contains the necessary files to get started easily with defining and executing processes. This wizard will set up a basic project structure, the classpath, a sample process and execution code to get you started. To create a new Drools project, simply left-click on the Drools action button (with the Drools head) in the Eclipse toolbar and select "New Drools Project". (Note that the Drools action button only shows up in the Drools perspective. To open the Drools perspective (if you haven't done so already), click the "Open Perspective" button in the top right corner of your Eclipse window, select "Other..." and pick the Drools perspective.) Alternatively, you could also select "File", then "New" followed by "Project ...", and in the Drools folder, select "Drools Project". This should open the following dialog:
Give your project a name and click "Next". In the following dialog you can select which elements are added to your project by default. Since we are creating a new process, deselect the first two checkboxes and select the last two. This will generate a sample process and a Java class to execute this process.
If you have not yet set up a Drools runtime, you should do this now. A Drools runtime is a collection of jars on your file system that represent one specific release of the Drools project jars. To create a runtime, you must either point the IDE to the release of your choice, or you can simply create a new runtime on your file system from the jars included in the Drools Eclipse plugin. Since we simply want to use the Drools version included in this plugin, we will do the latter. Note that you will only have to do this once; next time you create a Drools project, it will automatically use the default Drools runtime (unless you specify otherwise).
Unless you have already set up a Drools runtime, click the "Next" button. The following dialog, as displayed below, shows up, telling you that you have not yet defined a default Drools runtime and that you should configure the workspace settings first. Do this by clicking on the "Configure Workspace Settings ..." link.
The dialog that pops up shows the workspace settings for Drools runtimes. The first time you do this, the list of installed Drools runtimes is probably empty, as shown below. To create a new runtime on your file system, click the "Add..." button. This shows a dialog where you should give the new runtime a name (e.g. "Drools 5.0.0 runtime"), and a path to your Drools runtime on your file system. In this tutorial, we will simply create a new Drools 5 runtime from the jars embedded in the Drools Eclipse plugin. Click the "Create a new Drools 5 runtime ..." button and select the folder where you want this runtime to be stored and click the "OK" button. You will see the selected path showing up in the previous dialog. As we're all done here, click the "OK" button. You will see the newly created runtime shown in your list of Drools runtimes. Select this runtime as the new default runtime by clicking on the check box in front of your runtime name and click "OK". After successfully setting up your runtime, you can now finish the project creation wizard by clicking on the "Finish" button.
The end result should look like this and contains:
ruleflow.rf
: the process definition, which is a very
simple process containing
a Start node (the entry point), an Action node (that prints out "Hello World") and an
End node (the end of the process).
RuleFlowTest.java
: a Java class that executes the
process.
The necessary libraries are automatically added to the project classpath as a Drools library.
![]() |
By double-clicking the ruleflow.rf
file, the process will be
opened in the RuleFlow editor. The RuleFlow editor contains a graphical representation
of your process definition. It consists of nodes that are connected to each other.
The editor shows the overall control flow, while the
details of each of the elements can be viewed (and edited) in the Properties View at the bottom.
The editor contains a palette at the left that can be used to drag-and-drop new nodes, and an
outline view at the right.
This process is a simple sequence of three nodes. The Start node defines the start of the process. It is connected to an Action node (called "Hello" that simply prints out "Hello World" to the standard output. You can see this by clicking on the "Hello" node and checking the action property in the Properties View below. This node is then connected to an End node, signaling the end of the process.
While it is probably easier to edit processes using the graphical editor, users can also modify the underlying XML directly. The XML for our sample process is shown below (note that we did not include the graphical information here for simplicity). The process element contains parameters like the name and id of the process, and consists of three main subsections: a header (where information like variables, globals and imports can be defined), the nodes and the connections.
<?xml version="1.0" encoding="UTF-8"?> <process xmlns="http://drools.org/drools-5.0/process" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd" type="RuleFlow" name="ruleflow" id="com.sample.ruleflow" package-name="com.sample" > <header> </header> <nodes> <start id="1" name="Start" x="16" y="16" /> <actionNode id="2" name="Hello" x="128" y="16" > <action type="expression" dialect="mvel">System.out.println("Hello World");</action> </actionNode> <end id="3" name="End" x="240" y="16" /> </nodes> <connections> <connection from="1" to="2" /> <connection from="2" to="3" /> </connections> </process>