# Using OR-Tools Maven for Java

## 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

<br />

## 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](https://visualstudio.microsoft.com/downloads/?q=Visual+C%2B%2B+Redistributable+for+Visual+Studio) (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](https://java.com/en/download/help/download_options.xml).

### Maven

You must also have a Maven 64 bit installed.

You can find more details [here](https://maven.apache.org/download.cgi).

## 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](https://github.com/or-tools/java_or-tools) repository.

1. [Download the repository as a zip file](https://github.com/or-tools/java_or-tools/archive/v9.12.zip)
   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

<br />

## Run the example

From the `java_or-tools` directory:

Run the binary using:


    mvn exec:java

<br />

Congratulations! You've just run an application with OR-Tools, you are ready to
[get started with OR-Tools](https://developers.google.com/optimization/introduction/java).