1.3. Run the Examples

Procedure 1.2. To run the examples in your favorite IDE:

  1. Configure your IDE:
    • In IntelliJ and NetBeans, just open the file examples/sources/pom.xml as a new project, the Maven integration will take care of the rest.
    • In Eclipse, open a new project for the directory examples/sources.
    • Add all the jars to the classpath from the directory binaries and the directory examples/binaries, except for the file examples/binaries/optaplanner-examples-*.jar.
    • Add the Java source directory src/main/java and the Java resources directory src/main/resources.
  2. Next, create a run configuration:
    • Main class: org.optaplanner.examples.app.OptaPlannerExamplesApp
    • VM parameters (optional): -Xmx512M -server
    • Working directory: examples (this is the directory that contains the directory data)
  3. Run that run configuration.

Procedure 1.3.  Use Business Resource Planner with Maven, Gradle, Ivy, Buildr or ANT:

  1. Get the Business Resource Planner jars at the central maven repository (and also at the JBoss maven repository).
  2. If you use Maven, add a dependency to optaplanner-core in your project's pom.xml:
      <dependency>
          <groupId>org.optaplanner</groupId>
          <artifactId>optaplanner-core</artifactId>
          <version>...</version>
      </dependency>
    
    To identify the latest version, check the central maven repository. This is similar for Gradle, Ivy, and Buildr.
  3. If you're still using ANT (without Ivy), copy all the jars from the download zip's binaries directory and manually verify that your classpath doesn't contain duplicate jars.
Note
The download zip's binaries directory contains far more jars then optaplanner-core actually uses. It also contains the jars used by other modules, such as optaplanner-benchmark.
Check the Maven repository pom.xml files to determine the minimal dependency set for a specific version of a specific module.

Procedure 1.4.  Build Business Resource Planner from source:

  1. Set up Git and clone optaplanner from GitHub (or alternatively, download the zipball):
    $ git clone git@github.com:droolsjbpm/optaplanner.git optaplanner
    ...
  2. Do a Maven 3 build:
    $ cd optaplanner
    $ mvn -DskipTests clean install
    ...
  3. Run this command to run any example directly from the command line:
    $ cd optaplanner-examples
    $ mvn exec:exec
    ...
Note
Business Resource Planner will be known as Planner for the rest of this book.