Using OR-Tools Maven for Java

  • This guide provides step-by-step instructions for setting up and running OR-Tools in Java on Windows 10 64-bit using Maven.

  • Before starting, ensure you have prerequisites like Microsoft Visual C++ Redistributable, Java JDK 8 or later, and Maven installed.

  • You can integrate OR-Tools into your Maven project by adding a dependency to your project's pom.xml file.

  • Example code is available in the java_or-tools repository on GitHub and can be built and run using Maven commands.

  • After successfully running the example, you can explore further functionalities and features of OR-Tools for your Java applications.

 Introduction

This guide gets you started with OR-Tools in Java with a simple working example.

Although these instructions might also work on other Windows variants, we have only tested them on machines meeting the following requirements:

Windows 10 64-bit (x86_64) with:

  • Microsoft Visual Studio Enterprise 2022
  • Microsoft Visual Studio Community 2022 Preview 2 or above

Prerequisites

The following sections describe the prerequisites for installing OR-Tools.

Microsoft Visual C++ Redistributable

You must have the Microsoft Visual C++ Redistributable for Visual Studio 2022 (select the x64 version) installed on your computer, since OR-Tools library for Java is a wrapper for the C++ native library.

Java JDK

You must also have a Java JDK 64 bit, version 8.0 or later installed.

You can find more details here.

Maven

You must also have a Maven 64 bit installed.

You can find more details here.

Installing with Maven

To include OR-Tools in your Maven application, add a dependency on its artifacts to your project's pom.xml file. For example,

<!-- https://mvnrepository.com/artifact/com.google.ortools/ortools-java -->
<dependency>
    <groupId>com.google.ortools</groupId>
    <artifactId>ortools-java</artifactId>
    <version>9.12.4544</version>
</dependency>

Get the Java example code

The example code is located in the java_or-tools repository.

  1. Download the repository as a zip file and extract it, or clone the repository:

    git clone -b v9.12 --depth 1 https://github.com/or-tools/java_or-tools
    
  2. Change to the examples directory:

    cd java_or-tools
    

Build the example

From the java_or-tools directory:

Build the project using:

mvn compile -B

Run the example

From the java_or-tools directory:

Run the binary using:

mvn exec:java

Congratulations! You've just run an application with OR-Tools, you are ready to get started with OR-Tools.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-03-18 UTC.