Quantcast
Viewing all articles
Browse latest Browse all 5648

Sonatype tutorial has an error? I can't execute the basic jar.

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?

Viewing all articles
Browse latest Browse all 5648

Trending Articles