2

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:enter image description here

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

Edit One:

enter image description here

Edit Two:

enter image description here

Community
  • 1
  • 1
Victor Oliveira
  • 3,293
  • 7
  • 47
  • 77
  • Have you added them to the build path? – BlackHatSamurai Jun 28 '13 at 21:35
  • @Blaine I created the user library, them I imported the entire zip file. Which was working..then I went to Build Path and added the user library using the library import option..But the thing is if I import the entire zip its crashing for some reason, if I import only the jar it works...I would like to import the entire zip since I don't know what exactly I will need to use. – Victor Oliveira Jun 28 '13 at 21:40
  • Have you tried Cleaning the project? And what type of error do you get when it crashes? Is it your app that crashes or Eclipse? If it's your app can you post the crash log and stack trace? – BlackHatSamurai Jun 28 '13 at 21:41
  • @Blaine Crash was one way to express myself..it's not really crashing or giving me error on log file. I tryed to remove things from inside the zip such as "read me.txt" cos won't be useful but even though things are still not working =/ apparently the library is not compiling like the jre - When was working the jars were not showing, instead of were showing packages like up there in jre – Victor Oliveira Jun 28 '13 at 21:46
  • 1
    What files are all included in this Zip file? If it is other files like .txt & README's you can just extract and add. You don't need to add the whole thing, especially if it works with the .jar. The .jar is what contains all the code, the other stuff is just superfluous – BlackHatSamurai Jun 28 '13 at 21:47
  • @Blaine Check edit one please, there is the stuff you would like to know and inside lib stays all the jar files. – Victor Oliveira Jun 28 '13 at 21:50
  • It looks to me that all you need is the jar file. The other stuff is just licenses and other things that aren't needed to compile. – BlackHatSamurai Jun 28 '13 at 22:00
  • @Blaine I will what else I can do, but thanks for your support anyway brow – Victor Oliveira Jun 28 '13 at 22:03
  • @Blaine Take a look at the edit two, I tryed to add the jar using user library, just to customise the name of the library..then it says that the jar is missing but its currently not. It's there on the folder. – Victor Oliveira Jun 28 '13 at 22:13

3 Answers3

2

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.

Community
  • 1
  • 1
Victor Oliveira
  • 3,293
  • 7
  • 47
  • 77
0

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

Tom G
  • 3,650
  • 1
  • 20
  • 19
0

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.

  • 1
    Should be in the comments section, but you need some reputation to comment, I get that part as well. – Mahib Jul 12 '18 at 17:31