简体   繁体   English

如何在Eclipse中加载Google Collections Library?

[英]How do I load up Google Collections Library in Eclipse?

I'm currently trying to learn to use Guava so I downloaded the source by doing this: 我目前正在尝试学习使用番石榴,因此我通过执行以下操作下载了源代码:

svn checkout http://guava-libraries.googlecode.com/svn/trunk/ guava-libraries-read-only

Sorry if this sounds really stupid but for the life of me, I can't figure out how to load up the source in Eclipse to examine it. 抱歉,这听起来真的很愚蠢,但对我而言,我无法弄清楚如何在Eclipse中加载源代码以进行检查。 I've tried different ways (creating, importing, etc) but always end up with package problems. 我尝试了不同的方式(创建,导入等),但始终会遇到程序包问题。

I'm using Eclipse 3.5 on Ubuntu by the way. 顺便说一下,我在Ubuntu上使用Eclipse 3.5。

Can I get some help on this? 我可以在这方面寻求帮助吗? Thanks! 谢谢!

EDIT: I'm trying to examine the source so I would like to add the source as a project. 编辑:我正在尝试检查源,所以我想将源添加为一个项目。

Here is what I would do... 这是我会做的...

  1. Go to the downloads page and grab the latest bundled release 转到下载页面并获取最新的捆绑版本
  2. Unzip it to some local directory 解压缩到本地目录
  3. Copy the guava-r<version>.jar to your project's lib directory. guava-r<version>.jar复制到项目的lib目录。
  4. Right click on the JAR from Eclipse and say "Add to Build Path". 右键单击Eclipse中的JAR,然后说“添加到构建路径”。

If you need the source you can attach the guava-r<version>-src.jar in Eclipse via the Configure Build Path project menu or by using the attach source button during debug. 如果需要源代码,则可以在Eclipse中通过“ 配置构建路径”项目菜单或在调试过程中使用“ 附加源代码”按钮来附加guava-r<version>-src.jar

It's easiest to download a Jar from the Guava site , copy it into your Eclipse project and add it to the build path using the jar context menu > Build Path > Add to Build Path . 最简单的方法是从Guava站点下载Jar ,将其复制到Eclipse项目中,然后使用jar上下文菜单> Build Path> Add to Build Path将其添加到构建路径 Also, point Eclipse to the included source zip using project context menu > Configure Build Path... to get Javadoc on the Guava classes. 另外,使用项目上下文菜单> Configure Build Path ...将Eclipse指向随附的源zip 以获取有关Guava类的Javadoc。

I have done it two ways: the Subclipse and Maven eclipse plugins. 我有两种方法: SubclipseMaven eclipse插件。 Both offer "create project from repository"-like options. 两者都提供“从存储库创建项目”之类的选项。 Both plugins have reasonable online help, so I'll not repeat exact steps here. 这两个插件都有合理的在线帮助,因此在此不再赘述。

Creating a project from the repositories will give you a full view of the source (and documentation, build files, etc). 从存储库创建项目将为您提供源(以及文档,构建文件等)的完整视图。

I might be a little late in answering ... but you could also simply install the guava bundle from the update site " guava-bundle "; 我的回答可能有点晚了……但是您也可以直接从更新站点“ guava-bundle ”安装guava捆绑 it will install the sources along and you'll then just have to import the plugins in your workspace (File > Import > plugins and fragment... don't forget to tick the "projects with source folder" checkbox on the first page of this wizard) and browse the source from it. 它将安装源代码,然后您只需要在工作区中导入插件(“文件”>“导入”>“插件和片段......”,请不要忘了在第一页上选中“带有源文件夹的项目”复选框。此向导)并从中浏览源。

Note that this update site has now been discontinued in profit of Guava-osgi which also provide an update site for easy installation ... but I haven't installed it yet and thus don't know whether the sources are included in the artifacts installed through this update site. 请注意,此更新站点现已停止销售,以获取Guava-osgi的收益,该站点也提供了易于安装的更新站点...但是我尚未安装它,因此不知道源是否包含在已安装的工件中通过此更新站点。

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

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