How to run jsprit using maven

237 views Asked by At

Im new to using maven, and am trying to run the "SimpleExample.java" listed on the jsprit library github you can find the setup instructions here and the source code here.

I setup the directories as per some maven tutorials I found, and the contents of POM are as follows:

<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.springframework</groupId>
    <artifactId>gs-maven</artifactId>
    <packaging>jar</packaging>
    <version>0.1.0</version>

    <dependencies> <!-- add this, if you don't have any dependency definitions yet -->
      <dependency>
        <groupId>jsprit</groupId>
        <artifactId>jsprit-core</artifactId>
        <version>1.6</version>
      </dependency>
      <dependency>
        <groupId>jsprit</groupId>
        <artifactId>jsprit-analysis</artifactId>
        <version>1.6</version>
      </dependency>
      <dependency>
        <groupId>jsprit</groupId>
        <artifactId>jsprit-instances</artifactId>
        <version>1.6</version>
      </dependency>
    </dependencies> <!-- add this, if you don't have any dependency definitions yet -->

    <repositories> <!-- add this, if you don't have any repository definitions yet -->
      <repository>
        <id>jsprit-releases</id>
        <url>https://github.com/jsprit/mvn-rep/raw/master/releases</url>
      </repository>
    </repositories> <!-- add this, if you don't have any repository definitions yet -->

    <build>
    </build>
</project>

After running mvn compile -> mvn install -> mvn package. I go to the target directory and run the following command in my terminal:

java -cp gs-maven-0.1.0.jar test.SimpleExample

Note: my projects name is test. After running this command, I get the error below. Please advise if you know how to solve this issue. Thanks.

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: jsprit/core/problem/vehicle/VehicleType
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: jsprit.core.problem.vehicle.VehicleType
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more
0

There are 0 answers