Installation (Java Plugin for Choco)


  • This plugin is under development
  • It is supported by Choco 3 (not Choco 2).

The installation of the plugin will generate, in addition to the Ibex library, the libibex-java library that contains the glue code between C++ and Java.

Linux and MacOS

Uncompress the archive ibex-2.3.0.tar.gz in some Ibex folder:

~/Ibex/$ tar xvfz ibex-2.3.0.tar.gz

Uncompress the archive ibex-java.tar.gz in the plugin folder:

~/Ibex/$ tar xvfz ibex-java.tar.gz --directory=ibex-2.3.0/plugins

Set the environment variable JAVA_HOME. Typical paths are /Library/Java/Home (MacOS) or /usr/lib/jvm/java-7-openjdk-i38 (Linux). Example:

~/Ibex/$ export JAVA_HOME=/Library/Java/Home

Then configure Ibex as follows:

~/Ibex/$ cd ibex-2.3.0
~/Ibex/ibex-2.3.0/$ ./waf configure [...] --enable-shared --with-jni --with-java-package=org.chocosolver.solver.constraints.real

Note: the --enable-shared is mandatory.

Compiling and Running a Test Progam

Set the dynamic library paths.

  • Under Linux:

    ~$ export LD_LIBRARY_PATH=[prefix]/lib
  • Under MacOS:

    ~$ export DYLD_LIBRARY_PATH=[prefix]/lib

where [prefix] is /usr/local by default or whatever path specified via --prefix. Then:

~$ cd Ibex/ibex-2.3.0/__build__/src/java
~/Ibex/ibex-2.3.0/__build__/src/java$ java Test

Alternatively, you can give the library path directly in argument of the java command instead of using an environment variable:

~$ cd Ibex/ibex-2.3.0/__build__/src/java
~/Ibex/ibex-2.3.0/__build__/src/java$ java -Djava.library.path=[prefix]/lib Test



Under Windows, Ibex is compiled as a 32-bit library although the platform is 64 bits (this is mainly because the MinGW environment is 32-bits). Hence, Java will fail in loading Ibex unless you have a 32-bits JVM.

Under the shell of MinGW,

Uncompress the archive ibex-2.3.0.tar.gz in the Ibex folder (cf. instructions for the core library):

~/Ibex/$ tar xvfz ibex-2.3.0.tar.gz

Uncompress the archive ibex-java.tar.gz in the plugin folder:

~/Ibex/$ tar xvfz ibex-java.tar.gz --directory=ibex-2.3.0/plugins

Set the JAVA_HOME variable in Windows-style and with double backslash (“\”) as separator, e.g.:

~/Ibex/$ export JAVA_HOME=C:\\Java\\jdk1.7.1_17


The path must not contain white spaces, like ”...\Program Files\...”. Create a symbolik link of your Java directory if necessary.

Then, configure Ibex as follows:

~/Ibex/ibex-2.3.0/$ ./waf configure --prefix=C:\\MinGW\\msys\\1.0\\home\\[user]\\Ibex\\ibex-2.3.0 --enable-shared -with-jni --with-java-package=org.chocosolver.solver.constraints.real

And install Ibex as usual:

~/Ibex/ibex-2.3.0/$ ./waf install

Compiling and Running a Test Progam

We assume here that MinGW has been installed in C:\ and Ibex in C:\MinGW\msys\1.0\home\[user]\Ibex\ibex-2.3.0.

Open a command window (not the shell of MinGW) and type:

> set IBEX_PATH=C:\MinGW\msys\1.0\home\[user]\Ibex\ibex-2.3.0
> set PATH=%PATH%;%IBEX_PATH%\lib;C:\MinGW\bin
> cd %IBEX_PATH%\__build__\plugins\java\src
C:\MinGW\msys\1.0\home\[user]\Ibex\ibex-2.3.0\__build__\src\java>java -Djava.library.path=%IBEX_PATH%\lib Test

Configuration options

The IbexOpt plugin supports the following options (to be used with waf configure)

--with-jni Activate the Java plugin.
 The plugin will create the PACKAGE_NAME.jar file. This file is put into the [prefix]/share/java where [prefix] is /usr/local by default or whatever path specified via --prefix.


UnsatisfiedLinkError with Choco

When running the “CycloHexan” example from Choco using Ibex, the following error appears:

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.chocosolver.solver.constraints.real.Ibex.add_ctr(ILjava/lang/String;I)V
      at org.chocosolver.solver.constraints.real.Ibex.add_ctr(Native Method)
      at org.chocosolver.solver.constraint.propagators.real.RealPropagator.<init>(
      at org.chocosolver.solver.constraints.real.RealConstraint.addFunction(
      at samples.real.CycloHexan.buildModel(
      at samples.AbstractProblem.execute(
      at samples.real.CycloHexan.main(

Solution: You probably did not set the Java package properly. The java package of the Ibex class in Choco is org.chocosolver.solver.constraints.real, try:

./waf configure [....] --with-java-package=org.chocosolver.solver.constraints.real

JAVA_HOME does not seem to be set properly

I get this message when running waf configure.

Solution: The JAVA_HOME must be the path of the JDK and contain a subdirectoy include which, in turn, contains the jni.h header file. On MacOS this path can be /Library/Java/JavaVirtualMachines/jdkXXXX.jdk/Contents/Home.