When I right click on my Maven project and choose the Add dependency option and I type my external jar's name in query, it is not found. How to add external jar to a Maven project?
Approach 2: Include jar as part of the maven project. In this approach you need to first create a folder in your maven project & add your external jar file. Once the jar file is added, include the jar file in your pom using following notation.
In the project properties window, click on the Libraries node at the left Categories pane. Then on the right side, click on the Run tab and then click on the Add JAR/Folder button and browse the external JAR files you want to add, as shown in the below image. Then click on the OK button.
From the NetBeans forum:
group.id
(can be anything)artifact.id
(can be anything)1.0
(can be anything)Dependency is added to pom.xml
and appears under the Libraries node of Maven project. Continue:
Library is installed locally with dependency attributes (coordinates) entered in steps 4 - 6.
I found those instructions helpful when going through the NetBeans GUI. Basically when right clicking to add a dependency, the group id, version, and name must be populated with anything. Then that "dependency" will be listed in the dependency drop down. Right click on that newly created dependency and right click to install locally and navigate to the appropriate jar file.
You can follow this tutorial: http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
Example:
Install the jar to your local maven repository:
mvn install:install-file -Dfile=cxf-2.7.3.jar -DgroupId=org.apache.cxf -DartifactId=cxf-bundle -Dversion=2.7.3 -Dpackaging=jar
Edit the pom.xml file in your project to include the newly added dependency:
<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-bundle</artifactId> <version>2.7.3</version> </dependency>
This should work regardless of the IDE you are using.
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