I am trying to build an executable jar. When i execute the code from the project via eclipse, it runs fine, but not when the jar is executed from CMD line. Looks like some issue with class path, but i am not sure ...I have the following dependencies in my pom file:
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.12</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.12</version> <scope>compile</scope> </dependency> and the following maven plugins in the tag of the pom file:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>org.swx.nursing.tools.quicklaunch.executor.QuickLaunch</mainClass> </manifest> </archive> </configuration> </plugin> Then I use the following to build the jar: mvn clean install
When i execute the jar, i see the following message i am not sure why:
C:\Workspaces\CCQueryHotkey\quicklaunch\target>java -jar quicklaunch-0.0.1-SNAPSHOT.jar Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at org.swx.nursing.tools.quicklaunch.executor.QuickLaunch.<clinit>(QuickLaunch.java:18) Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 1 more I see that the SLF4j jars are in the project folder pulled by maven.
Please advise!
Thanks