Check the content of the jar file. Is there a file called (including path) /org/sonatype/mavenbook/App.class? Java says there isn't.
/Anders On Tue, Aug 13, 2013 at 12:01 PM, TenLeftFingers <[email protected]>wrote: > From the sonatype introduction to Maven > ( > http://books.sonatype.com/mvnex-book/reference/simple-project-sect-create-simple.html > ), > I've built a project following the instructions exactly. When I issue the > command: > > java -cp target/simple-1.0-SNAPSHOT.jar org.sonatype.mavenbook.App > > I get the error: > > Exception in thread "main" java.lang.NoClassDefFoundError: > org/sonatype/mavenbook/App > Caused by: java.lang.ClassNotFoundException: org.sonatype.mavenbook.App > at java.net.URLClassLoader$1.run(URLClassLoader.java:202) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:190) > at java.lang.ClassLoader.loadClass(ClassLoader.java:306) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) > at java.lang.ClassLoader.loadClass(ClassLoader.java:247) > Could not find the main class: org.sonatype.mavenbook.App. Program > will > exit. > > The project was created successfully: > mvn archetype:generate -DgroupId=org.sonatype.mavenbook.simple \ > -DartifactId=simple \ > -Dpackage=org.sonatype.mavenbook \ > -Dversion=1.0-SNAPSHOT > > and built: > $cd simple > $mvn install > > What can be wrong with my java command that causes this exception? > (the .java file is present as is the .jar) so what can be the problem with > the java command? > > > > -- > View this message in context: > http://maven.40175.n5.nabble.com/Sonatype-tutorial-has-an-error-I-can-t-execute-the-basic-jar-tp5767544.html > Sent from the Maven - Users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
