I am trying to compile and run this java project using maven. For this, Ive had to use a 3rd party Jar library, not found in the maven repository. I've been trying to tell maven to use this library on runtime (since it works perfectly fine at compile time, as I stated it on the POM file with no issues). I've tried several things such as using the Add-Jars plugin, adding it on the POM file as an external dependency:
<!--medpost-->
<dependency>
<groupId>lib.medpost</groupId>
<artifactId>medpost</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/medpost/medpost/1.0/medpost.jar</systemPath>
</dependency>
Among other things such as trying to indicate it as a command line argument, such as the first optional argument as shown in this API. It still throws a ClassNotFoundException. Any help is greatly appreciated.
First you need to install the custom JAR into your local Maven repository:
mvn install:install-file -Dfile=medpost.jar
-DgroupId=lib.medpost -DartifactId=medpost -Dversion=1.0
Then just put the following standard <dependency>
into your POM file:
<dependency>
<groupId>lib.medpost</groupId>
<artifactId>medpost</artifactId>
<version>1.0</version>
</dependency>
By default, the medpost.jar
will be available for both compilation and runtime, so you don't need to specify a scope unless you have a special need other than what your OP stated.
By the way, the likely reason you weren't having a problem during compilation is that your IDE had the JAR on its classpath. But when you actually tried running it, the dependency was not available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With