Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google OR-Tools: Could not run the java example, java.lang.UnsatisfiedLinkError: no jniortools in java.library.path

Tags:

java

or-tools

I a newbie in java, I wanna try google or-tools for vehicle routing problem

Just try to run java example from here

But I got this exception: java.lang.UnsatisfiedLinkError: no jniortools in java.library.path

There is a line of code which load system lib "jniortools". But I don't know where to get that lib.

I'm using mac osx.

Any ideas?

like image 371
pham cuong Avatar asked May 07 '18 04:05

pham cuong


1 Answers

OR-Tools is a C++ library with wrapper in Java using SWIG (which do JNI call etc...). I.e. this is a native library not a "pure" java lib...

So to use ortools in java you must tweak the java.library.path e.g. when using ortools from source and running a program from root_dir:

make third_party
make java
java -Djava.library.path=lib -cp objs:lib/com.google.ortools.jar:lib/protobuf.jar Program

note: ortools depends on protobuf.jar (which is compiled by ortools makefile third_party target rules)

documentation: https://developers.google.com/optimization/introduction/run_programs#running-the-java-example

like image 128
Mizux Avatar answered Oct 01 '22 16:10

Mizux