This guide explains how to install OR-Tools for Java on MacOS.
Although these instructions might also work on other MacOS variants, we have only tested them on machines meeting the following requirements:
- MacOS 12.2.1 (Monterey) 64-bit (x86_64)
The following sections describe the prerequisites for installing OR-Tools.
Xcode Command Line Tools
You must install the Xcode Command Line Tools. To do so, open the Terminal, found in
/Applications/Utilities/, and enter:
Click “Install” to download and install Xcode Command Line Tools. You don’t need to "Get Xcode" from the App Store. If you have a slow Internet connection, it may take many minutes.
Verify that you’ve successfully installed Xcode Command Line Tools:
You should see:
To install the remaining prerequisites, we recommend first installing the "missing package manager for macOS" otherwise known as Homebrew. To do so, open a terminal window and enter:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
To verify that you’ve successfully installed brew:
You should see:
Homebrew 1.6.9-8-g25542d7 Homebrew/homebrew-core (git revision 0e0c84; last commit 2018-06-20)
You must install the Java JDK 8.0 or higher.
Once you have installed Homebrew, you can install openjdk by opening a terminal window and enter:
Then you need to export the
brew install openjdk
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
You must install Maven.
Once you have installed Homebrew, you can install maven by opening a terminal window and enter:
brew install maven
You can test Maven is correctly installed and can find java using the following command:
Take the following steps to install the OR-Tools library for Java:
Download and extract the binary distribution for your system:
FlatZinc binary distributions
FlatZinc is a solver input language understood by a
wide range of solvers.
OR-Tools also provides binary distributions with FlatZinc support:
Validate your installation
To test your Java installations, open a terminal window and navigate to the directory where you unpacked the binary distribution. Then enter the following command:
This runs a selection of examples for OR-Tools. If all the examples run successfully, you are ready to get started with OR-Tools.