简体   繁体   中英

Jar folder becomes class folder under 'Referenced Libraries' in eclipse

I have a Java project in eclipse in which I would like to add 3 jar files to the build path:

生病1

However, when I select them and add them to the build path (right click / Build path / Add to build path), they are added to the 'Referenced Libraries' node along with the 'jars' folder that becomes a class folder:

生病2

Notice that the 'jars' folder directly under the project root can no longer expand as if it were empty.

Now this is fine for developing as the jars have been added to the build path, but problems appear when I try to export my project as a jar file (regular, not runnable):

在此处输入图片说明

The 'jars' folder appears empty and indeed is not exported with the class files when I check the resulting jar file. I have plenty of projects set up like this and it normally works. I switched versions to eclipse 4.3 but I still get the same behavior.

Can anyone help me out?

Juding by the icon for your jars-folder (note the tiny 010) you have configured it as a "class folder" on your build path. The contents of this don't seem to be exported into the jar-file.

To fix the issue got to your project's build-path configuration, under "libraries" you should find the jars-folder as class-file-folder. Select the entry, click "remove", export - and voila, everything should be there.

It's because that the particular jar file is added to build path as well as the folder containing the jar is added as Class Folder . Eg: ABC/xyz.jar

xyz.jar is added to build path using the option Add to Build Path and ABC is added to library using the option Add Class Folder using the Configure Build path wizard.

You may remove the folder from class folder and it will be resolved.

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