You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Ben Jakbot <be...@gmail.com> on 2008/08/22 00:46:44 UTC
starting with maven
hi
I try to start with maven and I'm sinking in tons of documentation.
Docs are a good thing, but I somehow miss the very obvious.
Right now I'm going through a the nice manual calling "Better Builds
with Maven". Basically I ran the following commands:
$mvn archetype:create -DgroupId=com.mycompany.app \
-DartifactId=my-app
$ cd my-app
$ mvn compile
$ mvn test
$ mvn test-compile
$ mvn package
$ mvn install
which magically generated my a project structure a hello world kind of
class and a test class for it. Then it compiled all the classes so
that I now have
$ ls target/
classes maven-archiver my-app-1.0-SNAPSHOT.jar surefire-reports test-classes
So my super simple task is complete this little roundtrip by running
the app "my-app-1.0-SNAPSHOT.jar". And the question is how can I run
it? Now I get the following error:
$ java target/my-app-1.0-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError:
target/my-app-1/0-SNAPSHOT/jar
I hoped not to have to mess around with classpathes. Could somebody
help me with this?
thanks in advance
ben
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: starting with maven
Posted by Wayne Fay <wa...@gmail.com>.
I assumed the mainClass had already been set in the manifest file.
Thanks for providing this config, Wim.
Ben, if you apply this configuration in your pom.xml, the -jar option
I provided will work. Then you can run your jar on any system that has
a JVM, and you will not need Maven installed (which the mvn exec:java
option obviously requires).
Wayne
On 8/22/08, Wim Deblauwe <wi...@gmail.com> wrote:
> An alternative is to turn your jar file into an executable jar file where
> you put your main class in the manifest file.
>
> <project>
> <build>
> <plugins>
> <plugin>
> <artifactId>maven-jar-plugin</artifactId>
> <configuration>
> <archive>
> <index>true</index>
> <manifest>
> <mainClass>com.mycompany.app.App</mainClass>
> <addClasspath>true</addClasspath>
> </manifest>
> </archive>
> </configuration>
> </plugin>
> </plugins>
> </build>
>
> Now you can use the -jar option to start your application.
>
> regards,
>
> Wim
>
>
> 2008/8/22 Ben Aurel <be...@gmail.com>
>
> > Alex, thank you. This is exactly what I was looking for. I got it running
> > with
> >
> > $ mvn exec:java -Dexec.mainClass=com.mycompany.app.App
> >
> >
> > On Thu, Aug 21, 2008 at 8:22 PM, Alex <pi...@googlemail.com> wrote:
> > > See http://mojo.codehaus.org/exec-maven-plugin/java-mojo.html
> > >
> > >
> > > Ben Jakbot wrote:
> > >>
> > >> hi
> > >> I try to start with maven and I'm sinking in tons of documentation.
> > >> Docs are a good thing, but I somehow miss the very obvious.
> > >>
> > >> Right now I'm going through a the nice manual calling "Better Builds
> > >> with Maven". Basically I ran the following commands:
> > >>
> > >> $mvn archetype:create -DgroupId=com.mycompany.app \
> > >> -DartifactId=my-app
> > >> $ cd my-app
> > >> $ mvn compile
> > >> $ mvn test
> > >> $ mvn test-compile
> > >> $ mvn package
> > >> $ mvn install
> > >>
> > >> which magically generated my a project structure a hello world kind of
> > >> class and a test class for it. Then it compiled all the classes so
> > >> that I now have
> > >>
> > >> $ ls target/
> > >> classes maven-archiver my-app-1.0-SNAPSHOT.jar
> > >> surefire-reports test-classes
> > >>
> > >> So my super simple task is complete this little roundtrip by running
> > >> the app "my-app-1.0-SNAPSHOT.jar". And the question is how can I run
> > >> it? Now I get the following error:
> > >>
> > >> $ java target/my-app-1.0-SNAPSHOT.jar
> > >> Exception in thread "main" java.lang.NoClassDefFoundError:
> > >> target/my-app-1/0-SNAPSHOT/jar
> > >>
> > >> I hoped not to have to mess around with classpathes. Could somebody
> > >> help me with this?
> > >>
> > >> thanks in advance
> > >> ben
> > >>
> > >> ---------------------------------------------------------------------
> > >> 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: starting with maven
Posted by Wim Deblauwe <wi...@gmail.com>.
An alternative is to turn your jar file into an executable jar file where
you put your main class in the manifest file.
<project>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<index>true</index>
<manifest>
<mainClass>com.mycompany.app.App</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Now you can use the -jar option to start your application.
regards,
Wim
2008/8/22 Ben Aurel <be...@gmail.com>
> Alex, thank you. This is exactly what I was looking for. I got it running
> with
>
> $ mvn exec:java -Dexec.mainClass=com.mycompany.app.App
>
>
> On Thu, Aug 21, 2008 at 8:22 PM, Alex <pi...@googlemail.com> wrote:
> > See http://mojo.codehaus.org/exec-maven-plugin/java-mojo.html
> >
> >
> > Ben Jakbot wrote:
> >>
> >> hi
> >> I try to start with maven and I'm sinking in tons of documentation.
> >> Docs are a good thing, but I somehow miss the very obvious.
> >>
> >> Right now I'm going through a the nice manual calling "Better Builds
> >> with Maven". Basically I ran the following commands:
> >>
> >> $mvn archetype:create -DgroupId=com.mycompany.app \
> >> -DartifactId=my-app
> >> $ cd my-app
> >> $ mvn compile
> >> $ mvn test
> >> $ mvn test-compile
> >> $ mvn package
> >> $ mvn install
> >>
> >> which magically generated my a project structure a hello world kind of
> >> class and a test class for it. Then it compiled all the classes so
> >> that I now have
> >>
> >> $ ls target/
> >> classes maven-archiver my-app-1.0-SNAPSHOT.jar
> >> surefire-reports test-classes
> >>
> >> So my super simple task is complete this little roundtrip by running
> >> the app "my-app-1.0-SNAPSHOT.jar". And the question is how can I run
> >> it? Now I get the following error:
> >>
> >> $ java target/my-app-1.0-SNAPSHOT.jar
> >> Exception in thread "main" java.lang.NoClassDefFoundError:
> >> target/my-app-1/0-SNAPSHOT/jar
> >>
> >> I hoped not to have to mess around with classpathes. Could somebody
> >> help me with this?
> >>
> >> thanks in advance
> >> ben
> >>
> >> ---------------------------------------------------------------------
> >> 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: starting with maven
Posted by Ben Aurel <be...@gmail.com>.
Alex, thank you. This is exactly what I was looking for. I got it running with
$ mvn exec:java -Dexec.mainClass=com.mycompany.app.App
On Thu, Aug 21, 2008 at 8:22 PM, Alex <pi...@googlemail.com> wrote:
> See http://mojo.codehaus.org/exec-maven-plugin/java-mojo.html
>
>
> Ben Jakbot wrote:
>>
>> hi
>> I try to start with maven and I'm sinking in tons of documentation.
>> Docs are a good thing, but I somehow miss the very obvious.
>>
>> Right now I'm going through a the nice manual calling "Better Builds
>> with Maven". Basically I ran the following commands:
>>
>> $mvn archetype:create -DgroupId=com.mycompany.app \
>> -DartifactId=my-app
>> $ cd my-app
>> $ mvn compile
>> $ mvn test
>> $ mvn test-compile
>> $ mvn package
>> $ mvn install
>>
>> which magically generated my a project structure a hello world kind of
>> class and a test class for it. Then it compiled all the classes so
>> that I now have
>>
>> $ ls target/
>> classes maven-archiver my-app-1.0-SNAPSHOT.jar
>> surefire-reports test-classes
>>
>> So my super simple task is complete this little roundtrip by running
>> the app "my-app-1.0-SNAPSHOT.jar". And the question is how can I run
>> it? Now I get the following error:
>>
>> $ java target/my-app-1.0-SNAPSHOT.jar
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> target/my-app-1/0-SNAPSHOT/jar
>>
>> I hoped not to have to mess around with classpathes. Could somebody
>> help me with this?
>>
>> thanks in advance
>> ben
>>
>> ---------------------------------------------------------------------
>> 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: starting with maven
Posted by Alex <pi...@googlemail.com>.
See http://mojo.codehaus.org/exec-maven-plugin/java-mojo.html
Ben Jakbot wrote:
> hi
> I try to start with maven and I'm sinking in tons of documentation.
> Docs are a good thing, but I somehow miss the very obvious.
>
> Right now I'm going through a the nice manual calling "Better Builds
> with Maven". Basically I ran the following commands:
>
> $mvn archetype:create -DgroupId=com.mycompany.app \
> -DartifactId=my-app
> $ cd my-app
> $ mvn compile
> $ mvn test
> $ mvn test-compile
> $ mvn package
> $ mvn install
>
> which magically generated my a project structure a hello world kind of
> class and a test class for it. Then it compiled all the classes so
> that I now have
>
> $ ls target/
> classes maven-archiver my-app-1.0-SNAPSHOT.jar surefire-reports test-classes
>
> So my super simple task is complete this little roundtrip by running
> the app "my-app-1.0-SNAPSHOT.jar". And the question is how can I run
> it? Now I get the following error:
>
> $ java target/my-app-1.0-SNAPSHOT.jar
> Exception in thread "main" java.lang.NoClassDefFoundError:
> target/my-app-1/0-SNAPSHOT/jar
>
> I hoped not to have to mess around with classpathes. Could somebody
> help me with this?
>
> thanks in advance
> ben
>
> ---------------------------------------------------------------------
> 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: starting with maven
Posted by Ben Aurel <be...@gmail.com>.
Sorry to bother you with this, but I get a 'Failed to load error'
$ java -jar target/my-app-1.0-SNAPSHOT.jar
Failed to load Main-Class manifest attribute from
target/my-app-1.0-SNAPSHOT.jar
On Thu, Aug 21, 2008 at 11:11 PM, Wayne Fay <wa...@gmail.com> wrote:
> I believe you're looking for:
> java -jar target/my-app-1.0-SNAPSHOT.jar
>
> Wayne
>
> On 8/21/08, Ben Jakbot <be...@gmail.com> wrote:
>> hi
>> I try to start with maven and I'm sinking in tons of documentation.
>> Docs are a good thing, but I somehow miss the very obvious.
>>
>> Right now I'm going through a the nice manual calling "Better Builds
>> with Maven". Basically I ran the following commands:
>>
>> $mvn archetype:create -DgroupId=com.mycompany.app \
>> -DartifactId=my-app
>> $ cd my-app
>> $ mvn compile
>> $ mvn test
>> $ mvn test-compile
>> $ mvn package
>> $ mvn install
>>
>> which magically generated my a project structure a hello world kind of
>> class and a test class for it. Then it compiled all the classes so
>> that I now have
>>
>> $ ls target/
>> classes maven-archiver my-app-1.0-SNAPSHOT.jar surefire-reports test-classes
>>
>> So my super simple task is complete this little roundtrip by running
>> the app "my-app-1.0-SNAPSHOT.jar". And the question is how can I run
>> it? Now I get the following error:
>>
>> $ java target/my-app-1.0-SNAPSHOT.jar
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> target/my-app-1/0-SNAPSHOT/jar
>>
>> I hoped not to have to mess around with classpathes. Could somebody
>> help me with this?
>>
>> thanks in advance
>> ben
>>
>> ---------------------------------------------------------------------
>> 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: starting with maven
Posted by Wayne Fay <wa...@gmail.com>.
I believe you're looking for:
java -jar target/my-app-1.0-SNAPSHOT.jar
Wayne
On 8/21/08, Ben Jakbot <be...@gmail.com> wrote:
> hi
> I try to start with maven and I'm sinking in tons of documentation.
> Docs are a good thing, but I somehow miss the very obvious.
>
> Right now I'm going through a the nice manual calling "Better Builds
> with Maven". Basically I ran the following commands:
>
> $mvn archetype:create -DgroupId=com.mycompany.app \
> -DartifactId=my-app
> $ cd my-app
> $ mvn compile
> $ mvn test
> $ mvn test-compile
> $ mvn package
> $ mvn install
>
> which magically generated my a project structure a hello world kind of
> class and a test class for it. Then it compiled all the classes so
> that I now have
>
> $ ls target/
> classes maven-archiver my-app-1.0-SNAPSHOT.jar surefire-reports test-classes
>
> So my super simple task is complete this little roundtrip by running
> the app "my-app-1.0-SNAPSHOT.jar". And the question is how can I run
> it? Now I get the following error:
>
> $ java target/my-app-1.0-SNAPSHOT.jar
> Exception in thread "main" java.lang.NoClassDefFoundError:
> target/my-app-1/0-SNAPSHOT/jar
>
> I hoped not to have to mess around with classpathes. Could somebody
> help me with this?
>
> thanks in advance
> ben
>
> ---------------------------------------------------------------------
> 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