1.3. Run the Examples

Procedure: 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: Use Business Resource Planner with Maven, Gradle, Ivy, Buildr or Ant:

  1. Get the Business Resource Planner JARs at the Central Repository (and also at the JBoss Nexus 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 Repository. This is similar for Gradle, Ivy, and Buildr.

  3. If you’re still using Ant (without Ivy), copy all the JARs from the downloaded ZIP’s binaries directory and manually verify that your classpath doesn’t contain duplicate JARs.
Note

The downloaded 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.

Note

Business Resource Planner will be known as Planner for the rest of this book.