Importing zip file as library - Eclipse Java

本秂侑毒 提交于 2019-12-11 12:33:52

问题


I stucked here importing google http library. I made some research in links such as:

  1. Eclipse, Java: How to import a library in zip-format?
  2. Import Libraries in Eclipse?

The thing is, I imported correctly and was working right. But after some point it stopped to work. I creater one user library, imported the zip file which contain the library but it's not sort of "compiling the library".

Take a look at the print, please:

I'm trying to solve on my own for four hours but I'm getting tired... could anyone help me please?

Edit One:

Edit Two:


回答1:


Did some more research and found this:

  1. How to add external library properly in Eclipse?

I then followed the steps:

  1. Extracted all google api content to one folder named lib
  2. Created a New User Librarby Window -> Preference -> Java -> Build Path -> New -> Name your library -> left the System Library unchecked -> Add External Jars -> manually added the needed jars.
  3. Right click on project folder -> Build Path -> Configure Build Path -> Libraries -> Add Library -> User Library -> checked the created user library.

In conclusion: Don't ever import the library as a zip or you will have a long headache.

Hope this helps someone else.

Edit: In case of some error showing up, like missing files belonging to the user library, cleaning the project may prove to be a solution. However, refreshing the project worked just fine for me. Try pressing F5 or right clicking on your project folder and select refresh.




回答2:


Right click on you class that you want to use the library in on the left hand panel in eclipse. Select "Build Path" => "Configure Build Path".

Click on the Libraries tab

Click on the "Add External Jars" button

Browse your file system for any .jar files(Java archives) that you want to include in your build path.

There you go.. you should now be able to use the archived classes in you code




回答3:


Seems like there is a shortcoming of Eclipse not being able to extract .jar files from .zip files (which is the form of many "combo" library packages out there). I wonder if there is a plugin or some other, easier way of directly adding .zip file to java projects via command line or some other way.



来源:https://stackoverflow.com/questions/17373997/importing-zip-file-as-library-eclipse-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!