Create an .jar executable with external .jar dependencies copied to the lib folder

I am using IntelliJ IDEA and Java. I have my main program called SearchEngine , which should create the SearchEngine.jar executable. However, in my code there are dependencies on 3 additional .jar files. I added these dependencies and my program is working fine.

I want to create an executable .jar file that does not include 3 additional .jar files inside it, but instead it copies them to the lib folder. For this, I chose the following option:

1

When I do not change the settings on the settings tab of the Artifacts project, I get 4 .jar files, 1 of which is my executable file, and 3 - additional .jar files. Thus, everything works perfectly.

2

However, when I try to add 3 additional .jars to the lib folder, my executable does not work , although 3 additional .jars are copied to lib . How to do it?

3

+5
source share
1 answer

Manually editing the MANIFEST.MF file as shown below (adding libs/ before each .jar name), fixed it.

Before:

 Class-Path: lucene-core-4.10.2.jar lucene-queryparser-4.10.2.jar lucen e-analyzers-common-4.10.2.jar 

After:

 Class-Path: libs/lucene-core-4.10.2.jar libs/lucene-queryparser-4.10.2.jar libs/lucene-analyzers-common-4.10.2.jar 
+4
source

All Articles