1

My project is built using Apache Maven JAR Plugin, I'm using ini4j inside my project managed by maven, on the IDE, everythin works fine. But when i try to launch the JAR in the cmd as follow : java -jar javaProgram-1.0-SNAPSHOT.jar

I get this error :

Exception in thread "main" java.lang.NoClassDefFoundError: org/ini4j/Ini
        at org.example.Main.main(Main.java:14)
Caused by: java.lang.ClassNotFoundException: org.ini4j.Ini
        at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        ... 1 more

Here is the manifest.mf inside the .jar:

Manifest-Version: 1.0
Class-Path: lib/ini4j-0.5.4.jar lib/maven-jar-plugin-3.2.2.jar lib/mav
 en-plugin-api-3.1.0.jar lib/maven-model-3.1.0.jar lib/org.eclipse.sis
 u.plexus-0.0.0.M2a.jar lib/cdi-api-1.0.jar lib/jsr250-api-1.0.jar lib
 /javax.inject-1.jar lib/guava-10.0.1.jar lib/jsr305-1.3.9.jar lib/sis
 u-guice-3.1.0-no_aop.jar lib/aopalliance-1.0.jar lib/org.eclipse.sisu
 .inject-0.0.0.M2a.jar lib/asm-3.3.1.jar lib/maven-core-3.1.0.jar lib/
 maven-settings-3.1.0.jar lib/maven-settings-builder-3.1.0.jar lib/mav
 en-repository-metadata-3.1.0.jar lib/maven-model-builder-3.1.0.jar li
 b/maven-aether-provider-3.1.0.jar lib/aether-spi-0.9.0.M2.jar lib/aet
 her-impl-0.9.0.M2.jar lib/aether-api-0.9.0.M2.jar lib/aether-util-0.9
 .0.M2.jar lib/plexus-interpolation-1.16.jar lib/plexus-classworlds-2.
 4.2.jar lib/plexus-component-annotations-1.5.5.jar lib/plexus-sec-dis
 patcher-1.3.jar lib/plexus-cipher-1.4.jar lib/maven-artifact-3.1.0.ja
 r lib/file-management-3.0.0.jar lib/maven-shared-io-3.0.0.jar lib/mav
 en-compat-3.0.jar lib/sisu-inject-plexus-1.4.2.jar lib/sisu-inject-be
 an-1.4.2.jar lib/sisu-guice-2.1.7-noaop.jar lib/wagon-provider-api-2.
 10.jar lib/maven-archiver-3.5.2.jar lib/commons-io-2.6.jar lib/common
 s-compress-1.20.jar lib/plexus-archiver-4.2.7.jar lib/plexus-io-3.2.0
 .jar lib/snappy-0.4.jar lib/xz-1.9.jar lib/maven-shared-utils-3.3.4.j
 ar lib/plexus-utils-3.3.1.jar
Build-Jdk-Spec: 1.8
Created-By: Maven JAR Plugin 3.2.2
Main-Class: org.example.Main

Any idea how i could provide everything while keeping maven? The goal would be to build the .jar and to launch it in the cmd instead of runnig it in the IDE

EDIT : This problem has been solved using the Apache Maven Shade Plugin allowing you to fix the problem by running the shaded jar.

Khysra
  • 25
  • 4

1 Answers1

0

This problem has been solved using the Apache Maven Shade Plugin allowing you to fix the problem by running the shaded jar.

Khysra
  • 25
  • 4