Title: Jar generated by NetBeans not running although it runs from the IDE
Tags: java;spring;maven;netbeans
Question: Here is my pom.xml.
<?xml version="1.0" encoding="UTF-8"?&gt;
<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"&gt;
<modelVersion&gt;4.0.0</modelVersion&gt;
<groupId&gt;com.mycompany</groupId&gt;
<artifactId&gt;TimeTrackerWithMaven</artifactId&gt;
<version&gt;1.0-SNAPSHOT</version&gt;
<packaging&gt;jar</packaging&gt;
<properties&gt;
<project.build.sourceEncoding&gt;UTF-8</project.build.sourceEncoding&gt;
<maven.compiler.source&gt;1.8</maven.compiler.source&gt;
<maven.compiler.target&gt;1.8</maven.compiler.target&gt;
<java.version&gt;1.8</java.version&gt;
</properties&gt;
<build&gt;
<plugins&gt;
<plugin&gt;
<groupId&gt;org.springframework.boot</groupId&gt;
<artifactId&gt;spring-boot-maven-plugin</artifactId&gt;
</plugin&gt;
<plugin&gt;
<groupId&gt;org.apache.maven.plugins</groupId&gt;
<artifactId&gt;maven-jar-plugin</artifactId&gt;
<version&gt;2.4</version&gt;
<configuration&gt;
<archive&gt;
<manifest&gt;
<addClasspath&gt;true</addClasspath&gt;
<mainClass&gt;com.mycompany.timetrackerwithmaven.Main</mainClass&gt;
</manifest&gt;
</archive&gt;
</configuration&gt;
</plugin&gt;
<plugin&gt;
<groupId&gt;org.jacoco</groupId&gt;
<artifactId&gt;jacoco-maven-plugin</artifactId&gt;
<version&gt;151.567-41-010502262128</version&gt;
<executions&gt;
<execution&gt;
<goals&gt;
<goal&gt;prepare-agent</goal&gt;
</goals&gt;
</execution&gt;
<execution&gt;
<id&gt;report</id&gt;
<phase&gt;prepare-package</phase&gt;
<goals&gt;
<goal&gt;report</goal&gt;
</goals&gt;
</execution&gt;
</executions&gt;
</plugin&gt;
</plugins&gt;
</build&gt;
<dependencies&gt;
<dependency&gt;
<groupId&gt;org.mockito</groupId&gt;
<artifactId&gt;mockito-core</artifactId&gt;
<version&gt;2.0.31-beta</version&gt;
</dependency&gt;
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io --&gt;
<dependency&gt;
<groupId&gt;org.apache.commons</groupId&gt;
<artifactId&gt;commons-io</artifactId&gt;
<version&gt;1.3.2</version&gt;
</dependency&gt;
<dependency&gt;
<groupId&gt;junit</groupId&gt;
<artifactId&gt;junit</artifactId&gt;
<version&gt;4.12</version&gt;
</dependency&gt;
<dependency&gt;
<groupId&gt;org.springframework</groupId&gt;
<artifactId&gt;spring-core</artifactId&gt;
<version&gt;4.2.4.RELEASE</version&gt;
</dependency&gt;
<dependency&gt;
<groupId&gt;org.springframework</groupId&gt;
<artifactId&gt;spring-test</artifactId&gt;
<version&gt;4.2.4.RELEASE</version&gt;
</dependency&gt;
<dependency&gt;
<groupId&gt;org.springframework</groupId&gt;
<artifactId&gt;spring-beans</artifactId&gt;
<version&gt;4.2.4.RELEASE</version&gt;
</dependency&gt;
<dependency&gt;
<groupId&gt;org.springframework</groupId&gt;
<artifactId&gt;spring-context</artifactId&gt;
<version&gt;4.2.4.RELEASE</version&gt;
</dependency&gt;
<dependency&gt;
<groupId&gt;com.google.code.gson</groupId&gt;
<artifactId&gt;gson</artifactId&gt;
<version&gt;2.4</version&gt;
</dependency&gt;
<dependency&gt;
<groupId&gt;com.google.guava</groupId&gt;
<artifactId&gt;guava</artifactId&gt;
<version&gt;19.0-rc2</version&gt;
</dependency&gt;
<dependency&gt;
<groupId&gt;com.google.collections</groupId&gt;
<artifactId&gt;google-collections</artifactId&gt;
<version&gt;1.0</version&gt;
</dependency&gt;
<dependency&gt;
<groupId&gt;net.java.dev.jna</groupId&gt;
<artifactId&gt;jna</artifactId&gt;
<version&gt;4.1.0</version&gt;
</dependency&gt;
<dependency&gt;
<groupId&gt;net.java.dev.jna</groupId&gt;
<artifactId&gt;platform</artifactId&gt;
<version&gt;3.5.2</version&gt;
</dependency&gt;
</dependencies&gt;
<name&gt;TimeTrackerWithMavenDevelopment</name&gt;
Here is my MANIFEST.MF in the generated jar.
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: Blackstorm
Class-Path: mockito-core-2.0.31-beta.jar byte-buddy-0.6.14.jar objenes
is-2.1.jar commons-io-1.3.2.jar junit-4.12.jar hamcrest-core-1.3.jar
spring-core-4.2.4.RELEASE.jar commons-logging-1.2.jar spring-test-4.2
.4.RELEASE.jar spring-beans-4.2.4.RELEASE.jar spring-context-4.2.4.RE
LEASE.jar spring-aop-4.2.4.RELEASE.jar aopalliance-1.0.jar spring-exp
ression-4.2.4.RELEASE.jar gson-2.4.jar guava-19.0-rc2.jar google-coll
ections-1.0.jar jna-4.1.0.jar platform-3.5.2.jar
Created-By: Apache Maven 3.0.5
Build-Jdk: 1.8.0_101
Main-Class: com.mycompany.timetrackerwithmaven.Main
When I run my code with "java -jar TimeTrackerWithMaven-1.0-SNAPSHOT.jar" I get the following error.
java.lang.NoClassDefFoundError: ruthschneider@example.net(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: ruthschneider@example.net(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main"

Here is the accepted answer: Your output jar don't have necessary libraries included and dependencies can't be found on classpath. To solve that, either include them on classpath (in your case, put them in the same folder as the output jar, there may be some plugins to help automate that, though this doesn't look like a giid idea, your folder will be polluted with tons of dependency jars, keeping it out of organize) or use maven-shade-plugin to merge those dependencies into output jar.
Comment for this answer: @aircraft Such an complaint won't be ruthschneider@example.net. If you have problems understanding my anwser, you should point out *what* confused you. You may open a seperate question to ask about it because this quesion has been inactive for quite a while.
Comment for this answer: I don't understand your mean.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:12/02/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<java><spring><maven><netbeans>', 'Title': 'Jar generated by NetBeans not running although it runs from the IDE', 'ViewCount': 288, 'id': 40941666, 'user_AboutMe': '', 'user_AccountId': 5756835.0, 'user_DisplayName': 'user', 'user_Reputation': 2155.0, 'user_Views': 40.0, 'user_id': 5159660.0}}