简体   繁体   English

为什么jar的父文件夹也出现在引用的库中?

[英]Why is parent folder of jar also showing up in referenced libraries?

I want to find out why is Eclipse exhibiting this kind of behaviour when I add my own custom runnable jar as an external jar in one of my projects. 我想找出为什么当我在一个项目中添加自己的自定义可运行jar作为外部jar时Eclipse表现出这种行为的原因。

It does not do this for any of the other jars I downloaded, such as gson or Spring Boots, but only for the jars I created from my projects. 它不对我下载的任何其他jar(例如gson或Spring Boots)执行此操作,而仅对我从项目中创建的jar执行此操作。

As you can see in the image below, both gson and my custom jar are in the same place but, when the gson jar was added, the downloads folder didn't show up in "Referenced Libraries". 如下图所示,gson和我的自定义jar都位于同一位置,但是,当添加gson jar时,downloads文件夹未显示在“ Referenced Libraries”中。 But, as soon as I added my custom jar, it shows up. 但是,一旦我添加了自定义jar,它就会显示出来。 Why is that so? 为什么会这样?

(I am adding these external jars via "configure buildpath" option) (我通过“ configure buildpath”选项添加这些外部jar)

在此处输入图片说明

I have managed to replicate this behaviour for executable jars. 我设法为可执行jar复制了此行为。 Actually, the problem is not with the executable nature, but with this line from manifest file: 实际上,问题不在于可执行文件的性质,而是清单文件中的这一行:

Class-Path: .

Because of the above line, everything within the current folder is added to classpath. 由于上面的行,当前文件夹中的所有内容都添加到了classpath中。

As a solution, remove the line from the generated MANIFEST file within the generated jar file, then add the jar to classpath. 解决方案是,从生成的jar文件中的生成的MANIFEST文件中删除该行,然后将jar添加到类路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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