Return-Path: X-Original-To: apmail-maven-users-archive@www.apache.org Delivered-To: apmail-maven-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3DD8A102E4 for ; Wed, 5 Feb 2014 19:40:54 +0000 (UTC) Received: (qmail 92636 invoked by uid 500); 5 Feb 2014 19:40:39 -0000 Delivered-To: apmail-maven-users-archive@maven.apache.org Received: (qmail 92576 invoked by uid 500); 5 Feb 2014 19:40:37 -0000 Mailing-List: contact users-help@maven.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Maven Users List" Reply-To: "Maven Users List" Delivered-To: mailing list users@maven.apache.org Received: (qmail 92428 invoked by uid 99); 5 Feb 2014 19:40:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Feb 2014 19:40:26 +0000 X-ASF-Spam-Status: No, hits=3.2 required=5.0 tests=HTML_MESSAGE,SPF_SOFTFAIL X-Spam-Check-By: apache.org Received-SPF: softfail (athena.apache.org: transitioning domain of jarlathreidy@gmail.com does not designate 216.139.236.26 as permitted sender) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Feb 2014 19:40:21 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1WB8KG-0001p1-IF for users@maven.apache.org; Wed, 05 Feb 2014 11:40:00 -0800 Date: Wed, 5 Feb 2014 11:40:00 -0800 (PST) From: TenLeftFingers To: users@maven.apache.org Message-ID: In-Reply-To: <52F28A38.4090909@yahoo.com> References: <1391622778030-5783294.post@n5.nabble.com> <52F28A38.4090909@yahoo.com> Subject: Re: Build is successful but can't run? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_264816_30144846.1391629200555" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_264816_30144846.1391629200555 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi Mark, Thanks for that. I changed the pom as you suggested. When I ran with java -jar myApp.jar I got the output: *Failed to load Main-Class manifest attribute from target/myApp.jar* I opened the manifest and the *Main-Class* attribute was entered as *mainClass.* So I changed it to the former and that got rid of that error. But now I *still *get the original error. The only pom change I'm not sure about is *lib/*. What classes is that classpath trying to capture? Thanks, Ten On Wed, Feb 5, 2014 at 7:01 PM, Mark Eggers [via Maven] < ml-node+s40175n5783298h15@n5.nabble.com> wrote: > 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 com.mycompany.app.App* 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 > > > org.apache.maven.plugins > maven-jar-plugin > 2.4 > > > true > main-class-name > true > lib/ > > > > > > 2. Use the maven-dependency-plugin to copy over the libraries > > > org.apache.maven.plugins > maven-dependency-plugin > 2.8 > > > package > > copy-dependencies > > > ${project.build.directory}/lib > compile > > > > > > 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: > > > > bin > > tar.gz > zip > > false > false > > > target > > > *.jar > lib/ > > > > > > Other ways include creating an uber-jar. > > . . . . just my two cents. > /mde/ > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://maven.40175.n5.nabble.com/Build-is-successful-but-can-t-run-tp5783294p5783298.html > To unsubscribe from Build is successful but can't run?, click here > . > NAML > -- View this message in context: http://maven.40175.n5.nabble.com/Build-is-successful-but-can-t-run-tp5783294p5783304.html Sent from the Maven - Users mailing list archive at Nabble.com. ------=_Part_264816_30144846.1391629200555--