How to use OrTools in Java (Spring Boot)

Viewed 306

I'm struggling to add OrTools to our Spring Boot project, basically what I've done is first try to add the dependency using gradle:

implementation 'com.google.ortools:ortools-java:9.2.9972'
implementation 'com.google.protobuf:protobuf-java:3.19.4'

But when using the CpModel we have an error on Protobuf even if it is downloaded by gradle:

java.lang.NoClassDefFoundError: com/google/protobuf/MessageOrBuilder

So I tried to load the dependency using the OrTools Loader:

Loader.loadNativeLibraries();

And Here I have another error and can't find the solution:

Resource ortools-darwin-aarch64/ was not found in ClassLoader jdk.internal.loader.ClassLoaders$AppClassLoader@3b192d32

Do you have any idea? Is there someone that has a working OrTools with spring?

(I'm on MacOS arm)

1 Answers

or-tools is a C++ library wrapped in java using swig. currently we only provide/support amd64 cpu arch and LInux/MacOS and windows platform.

I'll try to add a Java M1 issue but since we still don't have any M1 for testing and dev, don't expect support soon ;)

ps: https://github.com/google/or-tools/issues?q=apple+m1+

Related