简体   繁体   English

使用复制到lib文件夹中的外部.jar依赖关系构建可执行文件.jar

[英]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: 为此,我选择了以下选项:

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. 当我不更改Artifacts项目设置选项卡中的设置时,我会得到4个.jar文件,其中1个是我的可执行文件,3个是多余的.jar文件。 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. 但是,当我尝试将3个额外的.jar文件添加到lib文件夹中时,即使3个额外的.jars正在复制到lib文件夹中,我的可执行文件也无法工作 How to make this work ? 如何使这项工作?

3

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.

相关问题 包括可执行文件.jar的外部依赖项 - Include external dependencies for executable .jar 运行具有外部依赖项的可执行JAR - Running a executable JAR with external dependencies Eclipse:如何使用带有外部项目依赖项的ant构建可执行jar? - Eclipse: How to build an executable jar using ant with external project dependencies? Eclipse:如何使用外部jar构建可执行jar? - Eclipse: How to build an executable jar with external jar? Jar无法解析复制到其他文件夹中的依赖项 - Jar cannot resolve dependencies copied in other folder 在Eclipse中生成具有依赖项(外部jar)的可执行.jar - Generating an executable .jar with dependencies (external jars) in Eclipse 为可执行 JAR 文件提供外部依赖项 - Provide external dependencies to executable JAR file 对于外部jar,如果jar已存在/已复制到lib文件夹,是否有必要在pom.xml文件中添加具有系统路径的依赖项 - For an external jar, is it necessary to add a dependency in pom.xml file with a system path if jar already present/copied to lib folder 依赖关系未复制到jar中(在Gradle中) - Dependencies not copied into jar (in Gradle) 如何在Eclipse中使用其他外部jar依赖项创建一个不可运行/不可执行的jar - how to create a not runnable/not executable jar with other external jar dependencies in Eclipse
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM