Setting up a proper classpath when using maven?

When you executed mvn install for that library, it should have created a jar file and put it at target/libaryname-version. Jar . It would be better to depend on this final jar instead of the contents of the classes folder.

Maven also has a goal to download all dependencies of a project. You can execute.

Up vote 0 down vote favorite share g+ share fb share tw.

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. Java maven classpath link|improve this question asked Feb 21 at 22:07Tarun Chaudhry942110 100% accept rate.

When you executed mvn install for that library, it should have created a jar file and put it at target/libaryname-version.jar. It would be better to depend on this final jar instead of the contents of the classes folder. Maven also has a goal to download all dependencies of a project.

You can execute mvn dependency:copy-dependencies Inside 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 mvn dependency:copy-dependencies -DincludeScope=runtime.

Well, there are a couple issues at work here. Maven does the hard work of figuring out all the dependencies required for your library to be built and downloads them. These dependencies get stored locally in your Maven repository (/.

M2/repository), but unless they are needed as a part of an assembly you will not find them in the target folder. At least, not by default. What you need to do first is get Maven to store all dependencies in the build folder (this POM excerpt was cribbed from another SO post): ... qa maven-dependency-plugin install copy-dependencies ${project.build.

Directory}/lib With the POM changes shown above you should now be able to get all the JAR dependencies needed by your library and include them in your classpath (from target/lib). I would recommend copying them to another folder on your workstation, since the target folder will be nuked every time you execute the clean goal for the libraries Maven build. Now having said all that, why not adapt your project to use Maven as well?

Then all you would need to do is include the top level JAR as a dependency in your POM, and Maven would handle all its sub-dependencies? This is the power of Maven after all - it would be to your advantage to leverage it. In any case, good luck with whichever of the two approaches you select.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions