I’m using a library that uses Maven to compile and test.
I was able to compile the library without any problems. While compiling, it seemed as if it downloaded all the dependencies of the library.
Now, I’m trying to use the library in my project. When I compiled the library, I found that a folder called target was created in the library folder and inside that folder, there was another folder called classes. I added the classes folder to my classpath. However, whenever I try to use that library in my project which does not use Maven, it says that it can’t find that library’s dependencies.
How do I add all of that library’s dependencies to my classpath?
Do I need to go and manually download all the library’s dependencies and add them to the classpath?
Is there any way I can have Maven do that for me?
What do I need to do so that I can use the library in my project?
My project is in a completely separate directory than the library. Right now, my project seems to be able to load the library files correctly, but just not the library dependencies.
When you executed
mvn installfor that library, it should have created a jar file and put it attarget/libaryname-version.jar. It would be better to depend on this final jar instead of the contents of theclassesfolder. Maven also has a goal to download all dependencies of a project. You can executeInside the libraries folder and it will copy all dependency jars to
target/dependency. By default this will also include jars that are only needed for tests, to exclude these you could use