How to install Google OR-Tools for an IntelliJ project on Windows

653 views
Skip to first unread message

paul-emile Morgades

unread,
Sep 15, 2022, 3:41:22 AM9/15/22
to or-tools-discuss
Hello,

I'm trying to run the VRP Java examples for Google OR-Tools on Intellij Idea, but I don't know how to install it on Intellij IDEA.


This topic implies that I should  update the java.library.path in intelliJ Idea to point to the lib directory.
I have done it, in the Run/Debug configuration with the VM option:
-Djava.library.path=C:\Program Files\or-tools\or-tools_VisualStudio2022-64bit_v9.3.10497\lib\

Nevertheless, I get this error:
java: package com.google.ortools.constraintsolver does not exist.

Do you have any solution?

Thank you in advance.

Regards,

Kai Müller

unread,
Sep 15, 2022, 3:43:04 AM9/15/22
to or-tools-discuss
Hey,

have you tried using the maven dependencies?


I'm not quite sure if it's yet managed by google, but I think it was once more of a hobby / sideproject of someone.

Many Greetings.

Laurent Perron

unread,
Sep 15, 2022, 4:29:09 AM9/15/22
to or-tools-discuss
It's a bit more than a hobby :-)
It delayed the 9.4 release by 1 month just to support arm.

--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/28304830-adb0-46fb-9bc6-8a3b2c90957dn%40googlegroups.com.

paul-emile Morgades

unread,
Sep 15, 2022, 8:13:08 AM9/15/22
to or-tools-discuss
Thank you for your Answer.

I have tried the maven dependencies.

here is my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>untitled</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.ortools</groupId>
<artifactId>ortools-java</artifactId>
<version>9.4.1874</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>4.0.0-rc-2</version>
</dependency>
</dependencies>

</project>

Here is my file hierarchy:

scrrenshot.png

And here is the error I get when I try to execute Vrp:

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Platform
    at com.google.ortools.Loader.<clinit>(Loader.java:34)
    at org.example.Vrp.main(Vrp.java:83)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.Platform
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 2 more

Do you have any idea ?

Thank you.

Laurent Perron

unread,
Sep 15, 2022, 8:17:21 AM9/15/22
to or-tools-discuss
you need jna >= 5.5. from memory

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



Kai Müller

unread,
Sep 15, 2022, 8:46:30 AM9/15/22
to or-tools...@googlegroups.com
And if you're running inside a docker container, watch out for the correct base image. I had problems with the alpine image regarding the callback function on the solver.

Message has been deleted
Message has been deleted

paul-emile Morgades

unread,
Sep 15, 2022, 9:35:33 AM9/15/22
to or-tools-discuss
Thank it  you worked!

The jna jar was missing.

Thank you for the tip on docker.

Mizux Seiha

unread,
Sep 16, 2022, 3:01:28 AM9/16/22
to or-tools-discuss
1. Alpine is a libmusl based distro so our manylinux native package published on maven and using glibc will have hard time to work...
workaround: we provide distro specific pre-build on the github release page: https://github.com/google/or-tools/releases/tag/v9.4
e.g. https://github.com/google/or-tools/releases/download/v9.4/or-tools_amd64_alpine-edge_java_v9.4.1874.tar.gz

Otherwise we (I) provide two project template:
https://github.com/or-tools/maven_or-tools

* an older one (rusty) explaining how to install the jar file in your local maven cache.
https://github.com/or-tools/java_or-tools
note: will try to update it and use an Alpine based docker image.
Reply all
Reply to author
Forward
0 new messages