Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Guava to Eclipse project

Eclipse Helios 3.6
Windows XP SP3

I have used Eclipse to download the guava SDK by doing:
1) In Eclipse go to Help > Install New Software...
2) In the "Work with:" text box I used the following URL

http://svn.codespot.com/a/eclipselabs.org/guava-bundle/trunk/repository/

3) It found the Guava: Google Core Libraries for Java 1.5 Runtime and SDK, so I clicked ok to each message and they seemed to install fine.

Now I want to use it in my code (for an Android app) I am trying to add an import to one of my class files

import com.google.common.collect.MapMaker;

I get a compile error message

The import com.google cannot be resolved

Is there any special step I need to perform in order add the library to my project?

I have been looking through the project properties, I've got a feeling I need to add an entry to Java Build Path > Libraries but I do not know what to add.

like image 479
Martin Belcher - AtWrk Avatar asked Jan 10 '11 16:01

Martin Belcher - AtWrk


People also ask

What is guava used for Java?

Guava is an open-source “Collection Library” library for Java, developed by Google. It provides utilities for working with Java collections. As you dive deep into Guava you'll notice how it reduces coding errors, facilitates standard coding practices and boost productivity by making code concise and easy to read.

What is guava JRE version?

Guava: Google Core Libraries For Java » 24.0-jre Guava is a suite of core and expanded libraries that include utility classes, Google's collections, I/O classes, and much more. License.

What is the latest version of guava?

Guava 31.0. 1 was released September 27, 2021.


Video Answer


4 Answers

As far as i know Google Guava is not an Eclipse Plugin. It's a third party library. To add a lib to the Eclipse build path simply right click on your project -> build path -> configure build path -> libraries tab -> add external jars -> locate guava-r07.jar -> OK/OPEN

like image 164
Schildmeijer Avatar answered Oct 22 '22 03:10

Schildmeijer


Figured it out, you just need to add the path to the location of the SDK as a Link Source.

1) Right click project and choose Properties > Source > Link Source...
2) Browse to the location that eclipse downloaded the SDK to which on my computer was

C:\Program Files\eclipse\plugins\com.google.guava.source_1.7.0

like image 45
Martin Belcher - AtWrk Avatar answered Oct 22 '22 01:10

Martin Belcher - AtWrk


Just a little update here for everyone reading this in 2014. By now, there is an eclipse plugin for guava. It's part of the orbit project. A collection of useful third party libraries.

You can find the latest version here.

like image 24
Dave Avatar answered Oct 22 '22 01:10

Dave


For everyone reading this in 2016... download Guava from this link

and do the steps as @Schildmeijer noted...

like image 42
Mohamed Horani Avatar answered Oct 22 '22 02:10

Mohamed Horani