简体   繁体   中英

Build executable .jar with external .jar dependencies copied in a lib folder

I am using IntelliJ IDEA and Java. I have my main program, named SearchEngine which should build an executable SearchEngine.jar . However, there are dependencies in my code to 3 extra .jar files. I have added those dependencies and my program is working fine.

I want to build an executable .jar that does not include the 3 extra .jar files inside it, but instead, it copies them in a lib folder. For that matter I selected the following option:

1个

When I don't change the settings in the Artifacts project settings tab, I get 4 .jar files, 1 of which is my executable and 3 are the extra .jar files. This way, everything works fine.

2

However, when I try and add the 3 extra .jar files inside a lib folder, my executable does not work , even though the 3 extra .jars are getting copied in a lib folder. How to make this work ?

3

Manually editing the MANIFEST.MF file like below (adding libs/ in front of every .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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM