[英]Build executable .jar with external .jar dependencies copied in a lib folder
I am using IntelliJ IDEA and Java. 我正在使用IntelliJ IDEA和Java。 I have my main program, named SearchEngine
which should build an executable SearchEngine.jar
. 我有一个名为SearchEngine
主程序,该程序应构建一个可执行的SearchEngine.jar
。 However, there are dependencies in my code to 3 extra .jar files. 但是,我的代码中有3个额外的.jar文件具有依赖性。 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. 我想构建一个不包含3个额外.jar文件的可执行文件.jar,而是将其复制到lib
文件夹中。 For that matter I selected the following option: 为此,我选择了以下选项:
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. 当我不更改Artifacts项目设置选项卡中的设置时,我会得到4个.jar文件,其中1个是我的可执行文件,3个是多余的.jar文件。 This way, everything works fine. 这样一来,一切工作正常。
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. 但是,当我尝试将3个额外的.jar文件添加到lib
文件夹中时,即使3个额外的.jars正在复制到lib
文件夹中,我的可执行文件也无法工作 。 How to make this work ? 如何使这项工作?
Manually editing the MANIFEST.MF
file like below (adding libs/
in front of every .jar name), fixed it. 如下所述手动编辑MANIFEST.MF
文件(在每个.jar名称前添加libs/
),对其进行了修复。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.