I\'m trying to have mvn exec:exec
(or mvn exec:java
) run my program with a local jar in the classpath. However the jar fails to load:
In maven it is possible to include a local jar (which is outside of maven repository) using systemPath. But since the scope is system (for dependencies declared with systemPath), there are few limitations and because of that it only works with exec:java.
For exec:exec, the above solution will not work because maven does not include system scoped dependencies in its generated (runtime) classpath (%classpath) so the solution is to use your own classpath instead of maven generated classpath as shown below.
org.codehaus.mojo
exec-maven-plugin
1.2.1
exec
java
-classpath
local.jar;target/project-jar-with-dependencies.jar
xpress.audio.AudioProducer
Replace local.jar with all the jar files that are required to be present at some fixed location (here project root is assumed, where pox.xml is located). Also note the use of 'project-jar-with-dependencies.jar', in your case it should be target\XpressAudio-1.0-SN APSHOT-jar-with-dependencies.jar.