You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by jamborta <ja...@gmail.com> on 2009/10/13 11:22:50 UTC

Running Jar file created by Maven

Hi guys,

I'm new to Maven. I have this problem that I created a Maven project in
netbeans, added dependencies, and build it successfully, it runs in Netbeans
as well. but if I try to build it from the command prompt using mvn install,
it build the whole staff, but when I try to run the jar file, it just fails
becuase it cannot find the library files (dependencies), looks like maven
doesn't add those files, although it downloads them...
please help me, i'm looking for the answer for quite a while now.
thanks
Tom
-- 
View this message in context: http://www.nabble.com/Running-Jar-file-created-by-Maven-tp25869690p25869690.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Running Jar file created by Maven

Posted by Stevo Slavić <ss...@gmail.com>.
Seems shade plugin can have it's conflict resolution customized -
here<http://jira.codehaus.org/browse/MSHADE-43?focusedCommentId=164742&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_164742>is
solution for appending spring metadata. +1 for shade plugin features,
-1
for its documentation.

Regards,
Stevo.

On Tue, Oct 13, 2009 at 8:25 PM, Stevo Slavić <ss...@gmail.com> wrote:

> Just tried shade plugin, this<http://www.thekua.com/atwork/2008/10/generating-a-single-fat-jar-artifact-from-maven/>assembly plugin usage example, jar - maven-dependency-plugin combination,
> and fatjar - they all seem to do same thing, and it's not enough in some
> cases. Some libraries depend on their manifest metadata, like spring, and
> last man wins conflict resolution doesn't work in that case. I'm not legal
> expert but I think unpacking and repackaging libraries has legal
> consequences too.
>
> One-jar v0.96 used by most recent onejar-maven-plugin has some class loader
> bugs which prevents spring framework component scan feature to work. That
> bug is present for quite some time, one-jar library doesn't seem to be
> actively maintained.
>
> IMO, Java, language of the Web, is not best option for CLI.
>
> Regards,
> Stevo.
>
>
> On Tue, Oct 13, 2009 at 7:44 PM, Albert Kurucz <al...@gmail.com>wrote:
>
>> Which one is better?
>>
>> maven-jar-plugin/maven-dependency-plugin
>> maven-shade-plugin
>> onejar-maven-plugin
>> fatjar
>>
>> Why is that choice better than the other solutions?
>> Is the one which is "well maintained" always the better choice?
>> How do you define the "well maintained"-ness?
>> Just because it is debugged more frequently does it mean it is better?
>> It is possible that the other one did not have that much problems and
>> this is why it was not changed frequently.
>>
>> On Tue, Oct 13, 2009 at 10:58 AM, Will Hoover <ja...@gmail.com>
>> wrote:
>> > I would stick with the following
>> maven-jar-plugin/maven-dependency-plugin combo (also core plugins):
>> >
>> > <build>
>> >        <plugins>
>> >                <plugin>
>> >                        <artifactId>maven-jar-plugin</artifactId>
>> >                        <configuration>
>> >                                <archive>
>> >                                        <manifest>
>> >
>>  <mainClass>fully.qualified.MainClass</mainClass>
>> >                                        </manifest>
>> >                                </archive>
>> >                        </configuration>
>> >                </plugin>
>> >                <plugin>
>> >                        <artifactId>maven-dependency-plugin</artifactId>
>> >                        <executions>
>> >                                <execution>
>> >                                        <id>unpack-dependencies</id>
>> >                                        <phase>package</phase>
>> >                                        <goals>
>> >
>>  <goal>unpack-dependencies</goal>
>> >                                        </goals>
>> >                                </execution>
>> >                        </executions>
>> >                </plugin>
>> >        </plugins>
>> >        <resources>
>> >                <resource>
>> >
>>  <directory>${basedir}/target/dependency</directory>
>> >                </resource>
>> >        </resources>
>> > </build>
>> >
>> > -----Original Message-----
>> > From: Mark Struberg [mailto:struberg@yahoo.de]
>> > Sent: Tuesday, October 13, 2009 11:52 AM
>> > To: Maven Users List
>> > Subject: Re: Running Jar file created by Maven
>> >
>> > I'd use the maven-shade-plugin because a) it's a maven-core-plugin and
>> as such it's pretty well maintained b) it can also 'shade' concurring jars
>> into different packages if there are some dependency problems.
>> >
>> > LieGrue,
>> > strub
>> >
>> > --- On Tue, 10/13/09, Albert Kurucz <al...@gmail.com> wrote:
>> >
>> >> From: Albert Kurucz <al...@gmail.com>
>> >> Subject: Re: Running Jar file created by Maven
>> >> To: "Maven Users List" <us...@maven.apache.org>
>> >> Date: Tuesday, October 13, 2009, 5:40 PM
>> >> Always nice to have choices.
>> >> Now, which one is better, the onejar-maven-plugin or
>> >> fatjar?
>> >>
>> >> On Tue, Oct 13, 2009 at 7:15 AM, Stevo Slavić <ss...@gmail.com>
>> >> wrote:
>> >> > http://code.google.com/p/onejar-maven-plugin/
>> >> >
>> >> > http://anydoby.com/fatjar/
>> >> >
>> >> > Regards,
>> >> > Stevo.
>> >> >
>> >> > On Tue, Oct 13, 2009 at 2:03 PM, Marcin Kwapisz <
>> mkwapisz@zsk.p.lodz.pl>wrote:
>> >> >
>> >> >> > but if I try to build it from the command
>> >> prompt using mvn
>> >> >> > install,
>> >> >> > it build the whole staff, but when I try to
>> >> run the jar file, it just
>> >> >> > fails
>> >> >> > becuase it cannot find the library files
>> >> (dependencies), looks like
>> >> >> > maven
>> >> >> > doesn't add those files, although it
>> >> downloads them...
>> >> >>
>> >> >> [Marcin Kwapisz]
>> >> >> Maven does not pack jar into jar. You can use
>> >> assembly plugin to do that
>> >> >> (as Eric Lewis wrote), but you can also use
>> >> dependency plugin to copy
>> >> >> dependencies (needed libraries) to you Target
>> >> directory (or directory where
>> >> >> your main jar is located).
>> >> >>
>> >> >> Regards
>> >> >> Marcin Kwapisz
>> >> >>
>> >> >>
>> >> >>
>> >> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> >> >> For additional commands, e-mail: users-help@maven.apache.org
>> >> >>
>> >> >>
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> >> For additional commands, e-mail: users-help@maven.apache.org
>> >>
>> >>
>> >
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> > For additional commands, e-mail: users-help@maven.apache.org
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> > For additional commands, e-mail: users-help@maven.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>

Re: Running Jar file created by Maven

Posted by Stevo Slavić <ss...@gmail.com>.
Just tried shade plugin,
this<http://www.thekua.com/atwork/2008/10/generating-a-single-fat-jar-artifact-from-maven/>assembly
plugin usage example, jar - maven-dependency-plugin combination,
and fatjar - they all seem to do same thing, and it's not enough in some
cases. Some libraries depend on their manifest metadata, like spring, and
last man wins conflict resolution doesn't work in that case. I'm not legal
expert but I think unpacking and repackaging libraries has legal
consequences too.

One-jar v0.96 used by most recent onejar-maven-plugin has some class loader
bugs which prevents spring framework component scan feature to work. That
bug is present for quite some time, one-jar library doesn't seem to be
actively maintained.

IMO, Java, language of the Web, is not best option for CLI.

Regards,
Stevo.

On Tue, Oct 13, 2009 at 7:44 PM, Albert Kurucz <al...@gmail.com>wrote:

> Which one is better?
>
> maven-jar-plugin/maven-dependency-plugin
> maven-shade-plugin
> onejar-maven-plugin
> fatjar
>
> Why is that choice better than the other solutions?
> Is the one which is "well maintained" always the better choice?
> How do you define the "well maintained"-ness?
> Just because it is debugged more frequently does it mean it is better?
> It is possible that the other one did not have that much problems and
> this is why it was not changed frequently.
>
> On Tue, Oct 13, 2009 at 10:58 AM, Will Hoover <ja...@gmail.com>
> wrote:
> > I would stick with the following maven-jar-plugin/maven-dependency-plugin
> combo (also core plugins):
> >
> > <build>
> >        <plugins>
> >                <plugin>
> >                        <artifactId>maven-jar-plugin</artifactId>
> >                        <configuration>
> >                                <archive>
> >                                        <manifest>
> >
>  <mainClass>fully.qualified.MainClass</mainClass>
> >                                        </manifest>
> >                                </archive>
> >                        </configuration>
> >                </plugin>
> >                <plugin>
> >                        <artifactId>maven-dependency-plugin</artifactId>
> >                        <executions>
> >                                <execution>
> >                                        <id>unpack-dependencies</id>
> >                                        <phase>package</phase>
> >                                        <goals>
> >
>  <goal>unpack-dependencies</goal>
> >                                        </goals>
> >                                </execution>
> >                        </executions>
> >                </plugin>
> >        </plugins>
> >        <resources>
> >                <resource>
> >
>  <directory>${basedir}/target/dependency</directory>
> >                </resource>
> >        </resources>
> > </build>
> >
> > -----Original Message-----
> > From: Mark Struberg [mailto:struberg@yahoo.de]
> > Sent: Tuesday, October 13, 2009 11:52 AM
> > To: Maven Users List
> > Subject: Re: Running Jar file created by Maven
> >
> > I'd use the maven-shade-plugin because a) it's a maven-core-plugin and as
> such it's pretty well maintained b) it can also 'shade' concurring jars into
> different packages if there are some dependency problems.
> >
> > LieGrue,
> > strub
> >
> > --- On Tue, 10/13/09, Albert Kurucz <al...@gmail.com> wrote:
> >
> >> From: Albert Kurucz <al...@gmail.com>
> >> Subject: Re: Running Jar file created by Maven
> >> To: "Maven Users List" <us...@maven.apache.org>
> >> Date: Tuesday, October 13, 2009, 5:40 PM
> >> Always nice to have choices.
> >> Now, which one is better, the onejar-maven-plugin or
> >> fatjar?
> >>
> >> On Tue, Oct 13, 2009 at 7:15 AM, Stevo Slavić <ss...@gmail.com>
> >> wrote:
> >> > http://code.google.com/p/onejar-maven-plugin/
> >> >
> >> > http://anydoby.com/fatjar/
> >> >
> >> > Regards,
> >> > Stevo.
> >> >
> >> > On Tue, Oct 13, 2009 at 2:03 PM, Marcin Kwapisz <
> mkwapisz@zsk.p.lodz.pl>wrote:
> >> >
> >> >> > but if I try to build it from the command
> >> prompt using mvn
> >> >> > install,
> >> >> > it build the whole staff, but when I try to
> >> run the jar file, it just
> >> >> > fails
> >> >> > becuase it cannot find the library files
> >> (dependencies), looks like
> >> >> > maven
> >> >> > doesn't add those files, although it
> >> downloads them...
> >> >>
> >> >> [Marcin Kwapisz]
> >> >> Maven does not pack jar into jar. You can use
> >> assembly plugin to do that
> >> >> (as Eric Lewis wrote), but you can also use
> >> dependency plugin to copy
> >> >> dependencies (needed libraries) to you Target
> >> directory (or directory where
> >> >> your main jar is located).
> >> >>
> >> >> Regards
> >> >> Marcin Kwapisz
> >> >>
> >> >>
> >> >>
> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> >> For additional commands, e-mail: users-help@maven.apache.org
> >> >>
> >> >>
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Running Jar file created by Maven

Posted by Albert Kurucz <al...@gmail.com>.
Which one is better?

maven-jar-plugin/maven-dependency-plugin
maven-shade-plugin
onejar-maven-plugin
fatjar

Why is that choice better than the other solutions?
Is the one which is "well maintained" always the better choice?
How do you define the "well maintained"-ness?
Just because it is debugged more frequently does it mean it is better?
It is possible that the other one did not have that much problems and
this is why it was not changed frequently.

On Tue, Oct 13, 2009 at 10:58 AM, Will Hoover <ja...@gmail.com> wrote:
> I would stick with the following maven-jar-plugin/maven-dependency-plugin combo (also core plugins):
>
> <build>
>        <plugins>
>                <plugin>
>                        <artifactId>maven-jar-plugin</artifactId>
>                        <configuration>
>                                <archive>
>                                        <manifest>
>                                                <mainClass>fully.qualified.MainClass</mainClass>
>                                        </manifest>
>                                </archive>
>                        </configuration>
>                </plugin>
>                <plugin>
>                        <artifactId>maven-dependency-plugin</artifactId>
>                        <executions>
>                                <execution>
>                                        <id>unpack-dependencies</id>
>                                        <phase>package</phase>
>                                        <goals>
>                                                <goal>unpack-dependencies</goal>
>                                        </goals>
>                                </execution>
>                        </executions>
>                </plugin>
>        </plugins>
>        <resources>
>                <resource>
>                        <directory>${basedir}/target/dependency</directory>
>                </resource>
>        </resources>
> </build>
>
> -----Original Message-----
> From: Mark Struberg [mailto:struberg@yahoo.de]
> Sent: Tuesday, October 13, 2009 11:52 AM
> To: Maven Users List
> Subject: Re: Running Jar file created by Maven
>
> I'd use the maven-shade-plugin because a) it's a maven-core-plugin and as such it's pretty well maintained b) it can also 'shade' concurring jars into different packages if there are some dependency problems.
>
> LieGrue,
> strub
>
> --- On Tue, 10/13/09, Albert Kurucz <al...@gmail.com> wrote:
>
>> From: Albert Kurucz <al...@gmail.com>
>> Subject: Re: Running Jar file created by Maven
>> To: "Maven Users List" <us...@maven.apache.org>
>> Date: Tuesday, October 13, 2009, 5:40 PM
>> Always nice to have choices.
>> Now, which one is better, the onejar-maven-plugin or
>> fatjar?
>>
>> On Tue, Oct 13, 2009 at 7:15 AM, Stevo Slavić <ss...@gmail.com>
>> wrote:
>> > http://code.google.com/p/onejar-maven-plugin/
>> >
>> > http://anydoby.com/fatjar/
>> >
>> > Regards,
>> > Stevo.
>> >
>> > On Tue, Oct 13, 2009 at 2:03 PM, Marcin Kwapisz <mk...@zsk.p.lodz.pl>wrote:
>> >
>> >> > but if I try to build it from the command
>> prompt using mvn
>> >> > install,
>> >> > it build the whole staff, but when I try to
>> run the jar file, it just
>> >> > fails
>> >> > becuase it cannot find the library files
>> (dependencies), looks like
>> >> > maven
>> >> > doesn't add those files, although it
>> downloads them...
>> >>
>> >> [Marcin Kwapisz]
>> >> Maven does not pack jar into jar. You can use
>> assembly plugin to do that
>> >> (as Eric Lewis wrote), but you can also use
>> dependency plugin to copy
>> >> dependencies (needed libraries) to you Target
>> directory (or directory where
>> >> your main jar is located).
>> >>
>> >> Regards
>> >> Marcin Kwapisz
>> >>
>> >>
>> >>
>> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> >> For additional commands, e-mail: users-help@maven.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: Running Jar file created by Maven

Posted by Will Hoover <ja...@gmail.com>.
I would stick with the following maven-jar-plugin/maven-dependency-plugin combo (also core plugins):

<build>
        <plugins>
                <plugin>
                        <artifactId>maven-jar-plugin</artifactId>
                        <configuration>
                                <archive>
                                        <manifest>
                                                <mainClass>fully.qualified.MainClass</mainClass>
                                        </manifest>
                                </archive>
                        </configuration>
                </plugin>
                <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                                <execution>
                                        <id>unpack-dependencies</id>
                                        <phase>package</phase>
                                        <goals>
                                                <goal>unpack-dependencies</goal>
                                        </goals>
                                </execution>
                        </executions>
                </plugin>
        </plugins>
        <resources>
                <resource>
                        <directory>${basedir}/target/dependency</directory>
                </resource>
        </resources>
</build>

-----Original Message-----
From: Mark Struberg [mailto:struberg@yahoo.de] 
Sent: Tuesday, October 13, 2009 11:52 AM
To: Maven Users List
Subject: Re: Running Jar file created by Maven

I'd use the maven-shade-plugin because a) it's a maven-core-plugin and as such it's pretty well maintained b) it can also 'shade' concurring jars into different packages if there are some dependency problems.

LieGrue,
strub

--- On Tue, 10/13/09, Albert Kurucz <al...@gmail.com> wrote:

> From: Albert Kurucz <al...@gmail.com>
> Subject: Re: Running Jar file created by Maven
> To: "Maven Users List" <us...@maven.apache.org>
> Date: Tuesday, October 13, 2009, 5:40 PM
> Always nice to have choices.
> Now, which one is better, the onejar-maven-plugin or
> fatjar?
> 
> On Tue, Oct 13, 2009 at 7:15 AM, Stevo Slavić <ss...@gmail.com>
> wrote:
> > http://code.google.com/p/onejar-maven-plugin/
> >
> > http://anydoby.com/fatjar/
> >
> > Regards,
> > Stevo.
> >
> > On Tue, Oct 13, 2009 at 2:03 PM, Marcin Kwapisz <mk...@zsk.p.lodz.pl>wrote:
> >
> >> > but if I try to build it from the command
> prompt using mvn
> >> > install,
> >> > it build the whole staff, but when I try to
> run the jar file, it just
> >> > fails
> >> > becuase it cannot find the library files
> (dependencies), looks like
> >> > maven
> >> > doesn't add those files, although it
> downloads them...
> >>
> >> [Marcin Kwapisz]
> >> Maven does not pack jar into jar. You can use
> assembly plugin to do that
> >> (as Eric Lewis wrote), but you can also use
> dependency plugin to copy
> >> dependencies (needed libraries) to you Target
> directory (or directory where
> >> your main jar is located).
> >>
> >> Regards
> >> Marcin Kwapisz
> >>
> >>
> >>
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 


      

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Running Jar file created by Maven

Posted by Mark Struberg <st...@yahoo.de>.
I'd use the maven-shade-plugin because a) it's a maven-core-plugin and as such it's pretty well maintained b) it can also 'shade' concurring jars into different packages if there are some dependency problems.

LieGrue,
strub

--- On Tue, 10/13/09, Albert Kurucz <al...@gmail.com> wrote:

> From: Albert Kurucz <al...@gmail.com>
> Subject: Re: Running Jar file created by Maven
> To: "Maven Users List" <us...@maven.apache.org>
> Date: Tuesday, October 13, 2009, 5:40 PM
> Always nice to have choices.
> Now, which one is better, the onejar-maven-plugin or
> fatjar?
> 
> On Tue, Oct 13, 2009 at 7:15 AM, Stevo Slavić <ss...@gmail.com>
> wrote:
> > http://code.google.com/p/onejar-maven-plugin/
> >
> > http://anydoby.com/fatjar/
> >
> > Regards,
> > Stevo.
> >
> > On Tue, Oct 13, 2009 at 2:03 PM, Marcin Kwapisz <mk...@zsk.p.lodz.pl>wrote:
> >
> >> > but if I try to build it from the command
> prompt using mvn
> >> > install,
> >> > it build the whole staff, but when I try to
> run the jar file, it just
> >> > fails
> >> > becuase it cannot find the library files
> (dependencies), looks like
> >> > maven
> >> > doesn't add those files, although it
> downloads them...
> >>
> >> [Marcin Kwapisz]
> >> Maven does not pack jar into jar. You can use
> assembly plugin to do that
> >> (as Eric Lewis wrote), but you can also use
> dependency plugin to copy
> >> dependencies (needed libraries) to you Target
> directory (or directory where
> >> your main jar is located).
> >>
> >> Regards
> >> Marcin Kwapisz
> >>
> >>
> >>
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 


      

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Running Jar file created by Maven

Posted by Albert Kurucz <al...@gmail.com>.
Always nice to have choices.
Now, which one is better, the onejar-maven-plugin or fatjar?

On Tue, Oct 13, 2009 at 7:15 AM, Stevo Slavić <ss...@gmail.com> wrote:
> http://code.google.com/p/onejar-maven-plugin/
>
> http://anydoby.com/fatjar/
>
> Regards,
> Stevo.
>
> On Tue, Oct 13, 2009 at 2:03 PM, Marcin Kwapisz <mk...@zsk.p.lodz.pl>wrote:
>
>> > but if I try to build it from the command prompt using mvn
>> > install,
>> > it build the whole staff, but when I try to run the jar file, it just
>> > fails
>> > becuase it cannot find the library files (dependencies), looks like
>> > maven
>> > doesn't add those files, although it downloads them...
>>
>> [Marcin Kwapisz]
>> Maven does not pack jar into jar. You can use assembly plugin to do that
>> (as Eric Lewis wrote), but you can also use dependency plugin to copy
>> dependencies (needed libraries) to you Target directory (or directory where
>> your main jar is located).
>>
>> Regards
>> Marcin Kwapisz
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Running Jar file created by Maven

Posted by Stevo Slavić <ss...@gmail.com>.
http://code.google.com/p/onejar-maven-plugin/

http://anydoby.com/fatjar/

Regards,
Stevo.

On Tue, Oct 13, 2009 at 2:03 PM, Marcin Kwapisz <mk...@zsk.p.lodz.pl>wrote:

> > but if I try to build it from the command prompt using mvn
> > install,
> > it build the whole staff, but when I try to run the jar file, it just
> > fails
> > becuase it cannot find the library files (dependencies), looks like
> > maven
> > doesn't add those files, although it downloads them...
>
> [Marcin Kwapisz]
> Maven does not pack jar into jar. You can use assembly plugin to do that
> (as Eric Lewis wrote), but you can also use dependency plugin to copy
> dependencies (needed libraries) to you Target directory (or directory where
> your main jar is located).
>
> Regards
> Marcin Kwapisz
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: Running Jar file created by Maven

Posted by Marcin Kwapisz <mk...@zsk.p.lodz.pl>.
> but if I try to build it from the command prompt using mvn
> install,
> it build the whole staff, but when I try to run the jar file, it just
> fails
> becuase it cannot find the library files (dependencies), looks like
> maven
> doesn't add those files, although it downloads them...

[Marcin Kwapisz] 
Maven does not pack jar into jar. You can use assembly plugin to do that (as Eric Lewis wrote), but you can also use dependency plugin to copy dependencies (needed libraries) to you Target directory (or directory where your main jar is located). 

Regards
Marcin Kwapisz


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


AW: AW: Running Jar file created by Maven

Posted by Entner Harald <En...@afb.de>.
Have a look here: 

http://maven.apache.org/shared/maven-archiver/examples/classpath.html

-----Ursprüngliche Nachricht-----
Von: Entner Harald [mailto:Entner.Harald@afb.de] 
Gesendet: Dienstag, 13. Oktober 2009 11:50
An: Maven Users List
Betreff: AW: AW: Running Jar file created by Maven

How do you run the jar file? (outside netbeans). 

with java -jar .... ? 

If you do so, the jar files need to be included in the resulting jar file, or you have to add it to the classpath, via -cp ...

-----Ursprüngliche Nachricht-----
Von: jamborta [mailto:jamborta@gmail.com] 
Gesendet: Dienstag, 13. Oktober 2009 11:38
An: users@maven.apache.org
Betreff: Re: AW: Running Jar file created by Maven


it's a pure java project. and it runs OK inside netbeans. I get a
NoClassDefFoundError if try to run it from the command line:

Exception in thread "main" java.lang.NoClassDefFoundError:
cern/colt/function/In
tObjectProcedure
        at com.main.App.main(App.java:36)
Caused by: java.lang.ClassNotFoundException:
cern.colt.function.IntObjectProcedu
re
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        ... 1 more



What kind of project are you talking about? Is it a pure Java project or
does it run inside glassfish (for example)? What class files are missing?
How does the stacktrace look like? 

Try to add the missing artifacts to the pom.


-- 
View this message in context: http://www.nabble.com/Running-Jar-file-created-by-Maven-tp25869690p25869863.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: AW: AW: AW: Running Jar file created by Maven

Posted by jamborta <ja...@gmail.com>.
thanks a lot. it works now. :)


Entner Harald wrote:
> 
> No, it does not. It actually knows, which libraries are included and where
> they are (this includes also transitive dependencies.) but when you run
> java -jar only the generated jar is on the classpath, not the maven
> repository. So you have to tell maven, to include these artifacts inside
> the generated jar.
> 
> Fortunately there are a lot of plugins who can help you with this (so you
> don't have to include them manually.) I haven't used Maven for that
> purpose very often, but i have seen this plugin [1], which should help
> you. Maybe there is even an easier way, but i think this one is pretty
> straightforward. The plugin Mark suggested would do the job as well i
> think. So it is up to you which one to use.
> 
> with regards, 
> 
> Harald 
> 
> 
> [1]
> http://maven.apache.org/shared/maven-archiver/examples/classpath.html#Make
> 
> -----Ursprüngliche Nachricht-----
> Von: jamborta [mailto:jamborta@gmail.com] 
> Gesendet: Dienstag, 13. Oktober 2009 12:06
> An: users@maven.apache.org
> Betreff: Re: AW: AW: Running Jar file created by Maven
> 
> 
> yes, i run with java -jar
> 
> but when I run mvn install, I can see that it downloads all the
> dependencies. i thought it takes care of that automatically.
> 
> 
> Entner Harald wrote:
>> 
>> How do you run the jar file? (outside netbeans). 
>> 
>> with java -jar .... ? 
>> 
>> If you do so, the jar files need to be included in the resulting jar
>> file,
>> or you have to add it to the classpath, via -cp ...
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Running-Jar-file-created-by-Maven-tp25869690p25870160.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Running-Jar-file-created-by-Maven-tp25869690p25870320.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


AW: AW: AW: Running Jar file created by Maven

Posted by Entner Harald <En...@afb.de>.
No, it does not. It actually knows, which libraries are included and where they are (this includes also transitive dependencies.) but when you run java -jar only the generated jar is on the classpath, not the maven repository. So you have to tell maven, to include these artifacts inside the generated jar.

Fortunately there are a lot of plugins who can help you with this (so you don't have to include them manually.) I haven't used Maven for that purpose very often, but i have seen this plugin [1], which should help you. Maybe there is even an easier way, but i think this one is pretty straightforward. The plugin Mark suggested would do the job as well i think. So it is up to you which one to use.

with regards, 

Harald 


[1] http://maven.apache.org/shared/maven-archiver/examples/classpath.html#Make

-----Ursprüngliche Nachricht-----
Von: jamborta [mailto:jamborta@gmail.com] 
Gesendet: Dienstag, 13. Oktober 2009 12:06
An: users@maven.apache.org
Betreff: Re: AW: AW: Running Jar file created by Maven


yes, i run with java -jar

but when I run mvn install, I can see that it downloads all the
dependencies. i thought it takes care of that automatically.


Entner Harald wrote:
> 
> How do you run the jar file? (outside netbeans). 
> 
> with java -jar .... ? 
> 
> If you do so, the jar files need to be included in the resulting jar file,
> or you have to add it to the classpath, via -cp ...
> 
> 

-- 
View this message in context: http://www.nabble.com/Running-Jar-file-created-by-Maven-tp25869690p25870160.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: AW: AW: Running Jar file created by Maven

Posted by jamborta <ja...@gmail.com>.
yes, i run with java -jar

but when I run mvn install, I can see that it downloads all the
dependencies. i thought it takes care of that automatically.


Entner Harald wrote:
> 
> How do you run the jar file? (outside netbeans). 
> 
> with java -jar .... ? 
> 
> If you do so, the jar files need to be included in the resulting jar file,
> or you have to add it to the classpath, via -cp ...
> 
> 

-- 
View this message in context: http://www.nabble.com/Running-Jar-file-created-by-Maven-tp25869690p25870160.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: AW: AW: Running Jar file created by Maven

Posted by Mark Struberg <st...@yahoo.de>.
If it's really a standalone app, you can also use the maven-shade-plugin [1] for creating an 'uber-jar' which contains all the dependencies.

LieGrue,
strub

[1] http://maven.apache.org/plugins/maven-shade-plugin/

--- On Tue, 10/13/09, Entner Harald <En...@afb.de> wrote:

> From: Entner Harald <En...@afb.de>
> Subject: AW: AW: Running Jar file created by Maven
> To: "Maven Users List" <us...@maven.apache.org>
> Date: Tuesday, October 13, 2009, 11:50 AM
> How do you run the jar file? (outside
> netbeans). 
> 
> with java -jar .... ? 
> 
> If you do so, the jar files need to be included in the
> resulting jar file, or you have to add it to the classpath,
> via -cp ...
> 
> -----Ursprüngliche Nachricht-----
> Von: jamborta [mailto:jamborta@gmail.com]
> 
> Gesendet: Dienstag, 13. Oktober 2009 11:38
> An: users@maven.apache.org
> Betreff: Re: AW: Running Jar file created by Maven
> 
> 
> it's a pure java project. and it runs OK inside netbeans. I
> get a
> NoClassDefFoundError if try to run it from the command
> line:
> 
> Exception in thread "main" java.lang.NoClassDefFoundError:
> cern/colt/function/In
> tObjectProcedure
>         at
> com.main.App.main(App.java:36)
> Caused by: java.lang.ClassNotFoundException:
> cern.colt.function.IntObjectProcedu
> re
>         at
> java.net.URLClassLoader$1.run(Unknown Source)
>         at
> java.security.AccessController.doPrivileged(Native Method)
>         at
> java.net.URLClassLoader.findClass(Unknown Source)
>         at
> java.lang.ClassLoader.loadClass(Unknown Source)
>         at
> sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>         at
> java.lang.ClassLoader.loadClass(Unknown Source)
>         at
> java.lang.ClassLoader.loadClassInternal(Unknown Source)
>         ... 1 more
> 
> 
> 
> What kind of project are you talking about? Is it a pure
> Java project or
> does it run inside glassfish (for example)? What class
> files are missing?
> How does the stacktrace look like? 
> 
> Try to add the missing artifacts to the pom.
> 
> 
> -- 
> View this message in context: http://www.nabble.com/Running-Jar-file-created-by-Maven-tp25869690p25869863.html
> Sent from the Maven - Users mailing list archive at
> Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 


      

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


AW: AW: Running Jar file created by Maven

Posted by Entner Harald <En...@afb.de>.
How do you run the jar file? (outside netbeans). 

with java -jar .... ? 

If you do so, the jar files need to be included in the resulting jar file, or you have to add it to the classpath, via -cp ...

-----Ursprüngliche Nachricht-----
Von: jamborta [mailto:jamborta@gmail.com] 
Gesendet: Dienstag, 13. Oktober 2009 11:38
An: users@maven.apache.org
Betreff: Re: AW: Running Jar file created by Maven


it's a pure java project. and it runs OK inside netbeans. I get a
NoClassDefFoundError if try to run it from the command line:

Exception in thread "main" java.lang.NoClassDefFoundError:
cern/colt/function/In
tObjectProcedure
        at com.main.App.main(App.java:36)
Caused by: java.lang.ClassNotFoundException:
cern.colt.function.IntObjectProcedu
re
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        ... 1 more



What kind of project are you talking about? Is it a pure Java project or
does it run inside glassfish (for example)? What class files are missing?
How does the stacktrace look like? 

Try to add the missing artifacts to the pom.


-- 
View this message in context: http://www.nabble.com/Running-Jar-file-created-by-Maven-tp25869690p25869863.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: AW: Running Jar file created by Maven

Posted by jamborta <ja...@gmail.com>.
it's a pure java project. and it runs OK inside netbeans. I get a
NoClassDefFoundError if try to run it from the command line:

Exception in thread "main" java.lang.NoClassDefFoundError:
cern/colt/function/In
tObjectProcedure
        at com.main.App.main(App.java:36)
Caused by: java.lang.ClassNotFoundException:
cern.colt.function.IntObjectProcedu
re
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        ... 1 more



What kind of project are you talking about? Is it a pure Java project or
does it run inside glassfish (for example)? What class files are missing?
How does the stacktrace look like? 

Try to add the missing artifacts to the pom.


-- 
View this message in context: http://www.nabble.com/Running-Jar-file-created-by-Maven-tp25869690p25869863.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


AW: Running Jar file created by Maven

Posted by Entner Harald <En...@afb.de>.
What kind of project are you talking about? Is it a pure Java project or does it run inside glassfish (for example)? What class files are missing? How does the stacktrace look like? 

Try to add the missing artifacts to the pom.

-----Ursprüngliche Nachricht-----
Von: jamborta [mailto:jamborta@gmail.com] 
Gesendet: Dienstag, 13. Oktober 2009 11:23
An: users@maven.apache.org
Betreff: Running Jar file created by Maven


Hi guys,

I'm new to Maven. I have this problem that I created a Maven project in
netbeans, added dependencies, and build it successfully, it runs in Netbeans
as well. but if I try to build it from the command prompt using mvn install,
it build the whole staff, but when I try to run the jar file, it just fails
becuase it cannot find the library files (dependencies), looks like maven
doesn't add those files, although it downloads them...
please help me, i'm looking for the answer for quite a while now.
thanks
Tom
-- 
View this message in context: http://www.nabble.com/Running-Jar-file-created-by-Maven-tp25869690p25869690.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


AW: Running Jar file created by Maven

Posted by "Lewis, Eric" <Er...@ipi.ch>.
Hi Tom

The easiest way is to use the appassembler plugin.

Best regards,
Eric 

> -----Ursprüngliche Nachricht-----
> Von: jamborta [mailto:jamborta@gmail.com] 
> Gesendet: Dienstag, 13. Oktober 2009 11:23
> An: users@maven.apache.org
> Betreff: Running Jar file created by Maven
> 
> 
> Hi guys,
> 
> I'm new to Maven. I have this problem that I created a Maven 
> project in
> netbeans, added dependencies, and build it successfully, it 
> runs in Netbeans
> as well. but if I try to build it from the command prompt 
> using mvn install,
> it build the whole staff, but when I try to run the jar file, 
> it just fails
> becuase it cannot find the library files (dependencies), 
> looks like maven
> doesn't add those files, although it downloads them...
> please help me, i'm looking for the answer for quite a while now.
> thanks
> Tom
> -- 
> View this message in context: 
> http://www.nabble.com/Running-Jar-file-created-by-Maven-tp2586
> 9690p25869690.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org