Creating a Java Project for Rules

A Java™ Project for Rules is a predefined Java project that contains a single runnable main class to execute the rules contained in a rule project.

Before you begin

Before creating a Java project to execute a ruleset with an instance of the decision engine, you must select the build mode for your rule project.

About this task

To test a ruleset with the decision engine, you must first create a Java project. To create a Java project for ruleset execution, you use the Java Project for Rules page of Rule Designer.

Procedure

  1. Click File > New  >  Project.
  2. In the New Project wizard, select Java Project for Rules, and then click Next.
  3. In the Java Project for Rules page, type a name for your project in the Project name field and select a location to save the project:
    • If you want to save the project in your Eclipse workspace, keep the Use default box selected.
    • If you want to save your project to a different location, clear the Use default box and browse to select a directory in the Location field.
  4. Click Next.
  5. In the Java Project for Rules Settings page, specify the rule project that provides the ruleset for the Java project for rules, then click Next.
  6. In the Java Project for Rules Templates page, select one of the following templates:
    • Simple decision engine runner: Generates the main class of the Java project to execute a ruleset.
    • Simple decision engine test case: Generates a simple JUnit test case to execute a ruleset with the decision engine.
  7. Click Finish.
  8. When prompted to switch to the Java perspective, click Yes.

Results

The template Simple decision engine runner generates a simple class to execute a ruleset. A ruleset archive is also created at the root of the Java project for rules. The default archive name is ruleArchive1.dsar.

The Java project for rules also contains the rule engine library that is required to execute the decision engine.

What to do next

Before executing the Java application, edit the main class that was generated for the execution, see Completing the ruleset execution code.

To execute a Java project for rules, use the Java Application with Rules run configuration, see Running and debugging Java applications with rules.