[英]Eclipse IDE- Add jar? Add External jar? Add Library?
I want to integrate TwitterAPIME
to my Blackberry
project. 我想将
TwitterAPIME
集成到我的Blackberry
项目中。 I have 3 Jar files provided by TwitterAPIME
. 我有
TwitterAPIME
提供的3个Jar文件。 I am not sure how to link these 3 Jar files to my project. 我不知道如何将这3个Jar文件链接到我的项目。
My basic doubts are 我的基本疑虑是
What is an External Jar ? 什么是外部罐子? What is a Library ?
什么是图书馆?
What's the difference between Adding jar, Adding External jar or Adding Library ? 添加jar,添加外部jar或添加库有什么区别?
To add an External Jar file in Eclipse, follow these steps: Right Click on Project -> Select Build Path -> Select Configure Build Path -> Library Tab in the following Dialog box. 要在Eclipse中添加外部Jar文件,请按照下列步骤操作:在下面的对话框中右键单击项目 - >选择构建路径 - >选择配置构建路径 - >库选项卡。
A Library is a in-built Jar file from the JDK Directory or any other software eg J2ME-Polish as you can see in the Image above. 库是JDK目录中的内置Jar文件或任何其他软件,例如J2ME-Polish,如上图所示。 Normally these Library files are developed by a manufacturer.
通常,这些库文件是由制造商开发的。
Adding A Library: Clicking on the 4th Button will open a dialog box as below. 添加库:单击第4个按钮将打开如下对话框。
You can add different libraries installed on your system. 您可以添加系统上安装的不同库。 You can also add your own Library, by selecting "User Library".
您也可以通过选择“用户库”添加自己的库。
JAR: A JAR File in your workspace. JAR:工作空间中的JAR文件。
External JAR: A JAR File in your file system. 外部JAR:文件系统中的JAR文件。 Use it for test purposes only, otherwise your project would be quite untidy.
仅用于测试目的,否则您的项目将非常不整洁。
Library: Built-in libraries such as JUnit. 库:内置库,如JUnit。 You don't need to know their location, these come with Eclipse.
您不需要知道它们的位置,这些都来自Eclipse。
In addition to the excellent answer given above by Lucifer, I recommend that people looking to develop or use Libraries, review the following BB supplied KB article: 除了Lucifer上面给出的优秀答案之外,我建议那些希望开发或使用Libraries的人,查看以下BB提供的知识库文章:
Working with Libraries - shared, bundled, releasing, and using 3rd Party SDKs 使用库 - 共享,捆绑,发布和使用第三方SDK
Where the API is available as source or a Jar, I have found it significantly easier to include the source directly in the application. 如果API可用作源或Jar,我发现将源直接包含在应用程序中要容易得多。 For example, in this case, rather than include the TwitterAPIME jar, you could include the TwitterAPIME source as a separate project in the application.
例如,在这种情况下,您可以将TwitterAPIME源包含在应用程序中作为单独的项目,而不是包含TwitterAPIME jar。 As well as being easier to build, this can help in debugging or at least understanding issues with the API.
除了更容易构建之外,这还有助于调试或至少了解API的问题。
You might also find this sample, and in fact the containing Thread, useful: 您可能还会发现此示例,实际上包含Thread,非常有用:
Twitter + Facebook Sample Integration Twitter + Facebook样本整合
Also building on Lucifer's answer, I have used "User Libraries" to bundle jars that are used across projects and dependent on a 3rd party service. 同样基于路西法的答案,我使用“用户库”来捆绑跨项目使用并依赖于第三方服务的罐子。 Specifically, in my case, JMS jars.
具体来说,就我而言,JMS罐子。 If I upgrade to a new JMS, or a different provider, etc, I can simply change the jars in my User Library and all projects referencing this are updated.
如果我升级到新的JMS或其他提供商等,我只需更改用户库中的jar,并更新引用它的所有项目。 Rather than changing jar dependency in every project.
而不是在每个项目中更改jar依赖项。
An external Jar is a Jar in a path outh of your Eclipse environment: ie outside of both Eclipse jars and projects generated jars. 外部Jar是Eclipse环境中的一个Jar:即在Eclipse jar和项目生成的jar之外。
A libraray is a collection of jars prepared by someone for you. 图书馆是由某人为您准备的罐子集合。
You can cerate a User Library by selecting a group of external jars: that is useful if you have a group o jars that should logically work togehter. 您可以通过选择一组外部jar来终止用户库:如果您有一个逻辑上可以工作的组,那么这将非常有用。 A further advantage of creating a library is that you can "reuse it's definition" by referencing it in multiple projects.
创建库的另一个好处是,您可以通过在多个项目中引用它来“重用它的定义”。
Use: Project->Properties->Add library-> select "User library" and press Next->User libraries->New insert a new name and later us "Add Jar" that adds any jar you need to you library definition. 使用:项目 - >属性 - >添加库 - >选择“用户库”并按下Next->用户库 - >新建一个新名称,然后再添加“添加罐子”,将您需要的任何罐子添加到库定义中。 Later use this library in your project.
稍后在项目中使用此库。
Sometimes adding jars directly in the blackberry project might cause some build problems. 有时直接在blackberry项目中添加jar可能会导致一些构建问题。 Here 'sa solution that works (90%):
这是一个有效的解决方案(90%):
Java Project
. Java Project
。 Properties > Java Build Path
and choose Libraries
tab and click on Add External Jars
to add the 3 jars that are in your system and you want to use. Properties > Java Build Path
并选择Libraries
选项卡,然后单击Add External Jars
以添加系统中要使用的3个jar。 Then OK
. OK
Properties > Java Build Path
and click on the Projects
tab, click on Add
and select the project you just created and OK. Properties > Java Build Path
并单击Projects
选项卡,单击Add
并选择刚创建的Projects
,然后单击OK。 I hope this help. 我希望这有帮助。
如果在Eclipse工作区中添加JAR,请说/ myproject / WebRoot / WEB-INF / lib但是在使用Select Jar弹出窗口时Eclipse不显示/ lib,退出向导并刷新WebRoot(rtClick并执行Refresh或F5):Eclipse仅显示尚未添加到项目中的新库,通常需要先手动刷新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.