Using Maven 3.1
Eclipse Helios
Aspekt:
Try to create a runable jar file using maven-jar/dependency-plugins.
Problem:
Are you sure your java version, launched at command line, is equal or greater than that used by maven when compiling? try java -version
via command line, go to the parent dir of "dependency-jars" and run: java -jar program.jar
The simplest solution is to use maven-assembly-plugin like this:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<!-- NOTE: We don't need a groupId specification because the group is
org.apache.maven.plugins ...which is assumed by default.
-->
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
[...]
</project>
Ok, i solved the second/updated Problem:
I first startet to use eclipse with maven plugin to create the runable jar file. This runs in the described problems.
After all i tried to use maven 3.1 from console application and after all it works. Seems that eclipse maven plugin has some problems.
Not sure what's going on, but this is what my pom looks like for building a runnable jar using shade:
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>schema.xsd</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>stand-alone</shadedClassifierName>
<artifactSet>
<excludes>
<exclude>org.slf4j:slf4j-api:jar:</exclude>
<exclude>org.slf4j:slf4j-log4j12:jar:</exclude>
<exclude>org.slf4j:jcl-over-slf4j:jar:</exclude>
<exclude>commons-logging:commons-logging:jar:</exclude>
<exclude>commons-logging:commons-logging-api:jar:</exclude>
</excludes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<finalName>MyFinalRunnableJarName</finalName>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>class.with.main.Method</mainClass>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
</configuration>
</plugin>
</plugins>
</build>
Use this command to create jar file of any maven project.
mvn clean compile install