There are almost 10 local jars (these jars are required to build my application) in my Java application. I want them to add to the classpath using POM. How can I do that?
Asked
Active
Viewed 505 times
0
-
2why don't you add them to your local maven repository? – Scary Wombat Sep 11 '19 at 02:45
-
I want them to be part of project as they are required for compilation.Once my application build by Jenkin it will deploy to WebSphere where these jars will be referred by application through shared library(it will have all those local jars which are part of application) – gresa27 Sep 11 '19 at 02:59
-
and ...? why don't you add them to your local maven repository? – Scary Wombat Sep 11 '19 at 03:00
-
i am trying to find way to include the jars folder in POM itself rather than defining dependencies for each jar which need to be read from local in pom.Something like gradle which provide to include folder/directory dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) } – gresa27 Sep 11 '19 at 03:50
-
@gresa27 You can create a `fat.jar`? Add all to the pom and finally make a fat.jar file? – Hasitha Jayawardana Sep 11 '19 at 04:34
-
1Possible duplicate of [How to add local jar files to a Maven project?](https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-to-a-maven-project) – Sambit Sep 11 '19 at 06:24
-
1If you like to add them to the classpath you have to define them as dependencies in your pom file... – khmarbaise Sep 11 '19 at 06:59
-
A "folder of jars" is no valid concept in Maven. You need to define and manage the jars individually. – J Fabian Meier Sep 11 '19 at 11:55
1 Answers
0
You can add the dependency as system scope and refer to it by its full path. Consider that the JAR is located in /lib. Then add the dependency in your pom.xml file as following:
<dependency>
<groupId>com.abc.pqr</groupId>
<artifactId>sample-app</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/your_jar.jar</systemPath>
</dependency>
${basedir}
represents the directory containing pom.xml.

RITZ XAVI
- 3,633
- 1
- 25
- 35