Hi-
I am new to
maven. I felt I needed to change to it because fatjar for some reason went too slow. I made a maven project and did the 2 steps with goals compile and install. My problem is that it can't find the items on the class path. I read maven in 5 minutes and it says to run it like this: C:\Users\mtdew3q\workspace\my-app>
java -cp target/my-app-0.0.1-SNAPSHOT.jar com.
thirdshiftcoder.demoApp.Table_Demo
I am using eclipse with maven nature.
I get the message:
Exception in
thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widge
ts/Layout
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Layout
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: com.thirdshiftcoder.demoApp.Table_Demo. Program
will exit.
here is my .classpath file:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/swt"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/hibernate"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/derbyjars"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
this is my pom.xml
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.thirdshiftcoder.demoApp</groupId>
<artifactId>my-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>derbyDemo</name>
<description>hibernate and derby with maven</description>
</project>
To give you an idea of the structure of my directories/package I will do a print out:
my-app
src
main
java
com
thirdshiftcoder
demoApp
I added jars for hibernate, swt, and apache derby as libraries in my project. They are added from directories that start with c:\software for i.e. c:\software\hibernatejars or c:\software\swt to libraries in eclipse. When I select run as, with maven and compile goal, I don't get any errors. Run as with install goal seemed to work fine too. Are there any other goals I need besides compile and install?
Any cool tips would be appreciated. Maven is new to me. I think everything I need is in maven nature to deploy an app. I am just missing a trick.
When I run my other "java project" it works by outputting grid data from derbytours demo using hibernate and swt with apache derby.
One other thing of note off my c:\User\mtdew3q\.m2 there are jars for my project, and I am puzzled that I added swt as a library and it is in the repository, and maven can't see it as per the error message above. The first time I tried maven I tried to list dependencies in pom, but I later figured out that I didn't want anything downloaded because I already downloaded all the 3rdparty jars I need, so I deleted those dependencies out of pom.
thanks,
jim