maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wayne Fay <>
Subject Re: Build is successful but can't run?
Date Wed, 05 Feb 2014 18:23:05 GMT
> When I try to /run /it in the form of *java -cp
> target/my-app-1.0-SNAPSHOT.jar* I get this:
> *java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory*
> How come this dependency fails at this late stage?

This line says "run Java with the classpath being my-app.jar and use as the main/entry class."

Java says OK and happily tries to run your file. Then immediately
discovers that the classpath you have specified does not include one
or more classes - classes that you have declared as dependencies and
by using Maven to help manage during the compile process you don't
need to worry about the details of your classpath. This is exactly

But now you are dealing with run-time, not compile-time. Until now,
Maven has ensured that various dependencies are in the classpath --
but note that you are not running Maven, you are running Java, and
java does not know anything about Maven's pom and the dependencies
etc. So now you need to manually build out that classpath to run your
code with a lot more things in the -cp parameter.

A far simpler approach is to use the maven-exec-plugin and again let
Maven help with your run-time dependencies. Here is a link to that
documentation - I'm sure you can sort it out by click a few links and
doing 5 minutes of reading:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message