So I would like to build my maven project with
mvn clean package
But once I try to run my built jar file in target folder like
java -jar app-1.0-SNAPSHOT.jar
It shows error:
Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.NoClassDefFoundError: net/sourceforge/jdatepicker/DateModel 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: net.sourceforge.jdatepicker.DateModel 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
Pom DataPicker dependency:
<!-- https://mvnrepository.com/artifact/net.sourceforge.jdatepicker/jdatepicker -->
<dependency>
<groupId>net.sourceforge.jdatepicker</groupId>
<artifactId>jdatepicker</artifactId>
<version>1.3.2</version>
</dependency>
Why even though dependency was added, exception occurs?
Try deleting and redownloading the jar in your local maven repo.
If you are using idea, try updating the local repo in the maven setting.
You need to ensure all your dependencies are available to java runtime by adding them to your classpath. Adding a dependency in pom will help only in compiling and packaging the project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With