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 <[EMAIL PROTECTED]>

> 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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to