Le Mon, 8 Mar 2010 15:03:07 +0100,
"Matthias Hofmann" <[email protected]> a écrit :
> Hi,
>
> currently i am trying to get my Java program running outside of the
> Netbeans IDE. Within Netbeans, it works well, all dependencies are
> correctly loaded and executed.
> But if i try to run the program from the console with java -cp or java
> -jar, i get NoClassFoundDefError concerning the dependencies of the
> project.
>
- Use the plugin dependencies to obtain all required jar (for example put it in
target/lib)
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
- then in jar plugin tells it to use your prefix
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>...omitted...</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>./lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
Then you can launch your application via java -jar tar/XXX.jar
Works fine for us :) hope it will help you.
> My pom.xml uses
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-jar-plugin</artifactId>
> <configuration>
> <archive>
> <manifest>
> <mainClass>...omitted...</mainClass>
> <addClasspath>true</addClasspath>
> </manifest>
> </archive>
> </configuration>
> </plugin>
>
> as buildoptions
>
> Any ideas concerning this issue? Most likely, sth. with the classpath is
> wrong, but i can't figure it out.
>
> Best regards and thank you,
>
> Matthias
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
--
Tony Chemit
--------------------
tél: +33 (0) 2 40 50 29 28
email: [email protected]
http://www.codelutin.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]