maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Eggers <>
Subject Re: Build is successful but can't run?
Date Wed, 05 Feb 2014 19:00:08 GMT
On 2/5/2014 9:52 AM, TenLeftFingers wrote:
> When I build my Maven project with dependencies (using Netbeans but pointing
> to a vanilla Maven installation), I get BUILD SUCCESS. Great!
> 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?
> Trying to run the class from NetBeans itself gives a different error:
> *Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec*
> Please enlighten me as to how I can run this thing. It works fine in Eclipse
> when I run it as a Java Application - but Eclipse has other problems that
> I'm avoiding so I need to do this either from CLI or NetBeans (preferable).
> Thanks,
> Ten

I normally use NetBeans . . . .

One way to handle this (and it'll end up looking like a standard 
NetBeans project) is the following.

1. Modify the manifest via the maven-jar-plugin


2. Use the maven-dependency-plugin to copy over the libraries


3. Run from the command line to test

mvn package
cd target
java -jar jarFileName.jar

To ship the binaries, use the maven-assembly-plugin and package both the 
JAR and the supporting libraries. That way when someone unpacks the zip 
(or tar or tar.gz, etc.), the directory structure will be maintained.

Here's an assembly.xml file. I've left out the xml namespace declarations:

<?xml version="1.0" encoding="UTF-8"?>

Other ways include creating an uber-jar.

. . . . just my two cents.

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

View raw message