how to add jar dependency in maven?

user3217883

When I run

mvn compile

I get package com.ibm.icu.util does not exist. So I downloaded the ICU4J jar and installed it into the local repository. I confirmed it's in .m2/repository/com/ibm/icu/icu4j/3.4.4/icu4j-3.4.4.jar. Inside that jar file is the missing class file com/ibm/icu/util/Calendar.class. Then I added the following into the dependencies section of pom.xml:

<dependency>
   <groupId>com.ibm.icu</groupId>
   <artifactId>icu4j</artifactId>
   <version>3.4.4</version>
</dependency>

But when I run mvn compile again, I get the same error. What am I doing wrong?

Jon

You should not be manually installing things into the maven repository directory. That directory is maintained by maven itself.

The way dependencies work is that when you run mvn compile or some other goal, it will connect to the maven central repository and download the needed dependencies and their dependencies.

If you manually install a jar file, it may not have it's dependencies. That icu artifact will likely have other things it depends on. Maven will automatically resolve these dependencies.

I would recommend using mvn clean install this will clean the target directory and rebuild everything.

If it fails to download, then you likely need to change the maven configuration. For example, if you are behind a proxy server you need to configure maven with the proxy credentials.

Also, if you manually copied anything into the .m2/repository/ directory you should delete it and let maven put it in there correctly instead.

The beauty of maven is that you don't need to worry about things like downloading jars. It just handles that for you. Let it do it's job.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to add local jar to fat jar as a dependency using maven?

From Dev

How to add Maven dependency jar file from the lib folder

From Dev

Eclipse - How to add a project as a Maven dependency to another, instead of adding as a jar?

From Dev

How to add local project (not jar) as a dependency to a Maven project

From Dev

How to add dependency to maven project? (How to find out GroupID / ArtifactID from external jar file)

From Dev

How to get path to dependency jar with maven

From Dev

How to find the usage of a jar imported by maven dependency?

From Dev

How to add\install to maven dependency of newly created\third party jar in pom.xml

From Dev

Maven won't add local dependency to target jar

From Dev

maven: create a jar from generated sources and add it as a dependency before compiling

From Dev

Need to create Java JAR file and add it to Maven Dependency

From Dev

Maven won't add local dependency to target jar

From Dev

Maven dependency to jar in Nexus

From Dev

maven: how to build the dependency from source.jar to jar files and put the jar file as it dependency?

From Dev

How to add a local jar dependency to another dependency in gradle?

From Dev

How to add a local jar dependency to another dependency in gradle?

From Dev

How can I add JDT as a Maven dependency?

From Dev

How to add a Maven project as a Gradle dependency?

From Dev

How can I add LIRE dependency to Maven?

From Dev

How to download sources for an specific JAR dependency of a Maven project

From Dev

How to use maven assembly plugin to exclude a package from dependency jar?

From Dev

How can I include a set of jar's as a single dependency in Maven?

From Dev

How can I remove maven dependency jar in Eclipse

From Dev

How to define maven test-jar dependency in sbt

From Dev

How to create a jar with Maven that includes dependencies in a separate folder for each dependency

From Dev

How are dependency binaries included in my final built and installed .JAR in Maven?

From Dev

How to define the maven dependency, if jar is already included in project

From Dev

Add a module dependency in Maven

From Java

How to add local jar files to a Maven project?

Related Related

  1. 1

    How to add local jar to fat jar as a dependency using maven?

  2. 2

    How to add Maven dependency jar file from the lib folder

  3. 3

    Eclipse - How to add a project as a Maven dependency to another, instead of adding as a jar?

  4. 4

    How to add local project (not jar) as a dependency to a Maven project

  5. 5

    How to add dependency to maven project? (How to find out GroupID / ArtifactID from external jar file)

  6. 6

    How to get path to dependency jar with maven

  7. 7

    How to find the usage of a jar imported by maven dependency?

  8. 8

    How to add\install to maven dependency of newly created\third party jar in pom.xml

  9. 9

    Maven won't add local dependency to target jar

  10. 10

    maven: create a jar from generated sources and add it as a dependency before compiling

  11. 11

    Need to create Java JAR file and add it to Maven Dependency

  12. 12

    Maven won't add local dependency to target jar

  13. 13

    Maven dependency to jar in Nexus

  14. 14

    maven: how to build the dependency from source.jar to jar files and put the jar file as it dependency?

  15. 15

    How to add a local jar dependency to another dependency in gradle?

  16. 16

    How to add a local jar dependency to another dependency in gradle?

  17. 17

    How can I add JDT as a Maven dependency?

  18. 18

    How to add a Maven project as a Gradle dependency?

  19. 19

    How can I add LIRE dependency to Maven?

  20. 20

    How to download sources for an specific JAR dependency of a Maven project

  21. 21

    How to use maven assembly plugin to exclude a package from dependency jar?

  22. 22

    How can I include a set of jar's as a single dependency in Maven?

  23. 23

    How can I remove maven dependency jar in Eclipse

  24. 24

    How to define maven test-jar dependency in sbt

  25. 25

    How to create a jar with Maven that includes dependencies in a separate folder for each dependency

  26. 26

    How are dependency binaries included in my final built and installed .JAR in Maven?

  27. 27

    How to define the maven dependency, if jar is already included in project

  28. 28

    Add a module dependency in Maven

  29. 29

    How to add local jar files to a Maven project?

HotTag

Archive