简体   繁体   中英

Eclipse IDE- Add jar? Add External jar? Add Library?

I want to integrate TwitterAPIME to my Blackberry project. I have 3 Jar files provided by TwitterAPIME . I am not sure how to link these 3 Jar files to my project.

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 ?

What is an External JAR?

  • External as the name suggest is a Jar file that is not built by the currently developing code. It is a utility Jar file that is added externally for extra features. It could be an API Jar file provided from the external site, just as in your case the 3 Jar files will be going to call External Jar Files.
  • 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.

What is a Library?

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. Normally these Library files are developed by a manufacturer.

What's the difference between adding JAR, Adding External JAR, and Adding Library?

  • Adding Jar File: When you have more than one project in Eclipse and you add another project's Jar file, that is called adding Jar File. There is a first Button in the Photo above, it only allows you to add Jar file from the other Project.
  • Adding External Jar: When you add any API Jar file provided by the site or another manufacturer. In your case the 3 Jar files are External Jar Files. You can add then by using second Button "Add External JARs".
  • Adding A Library: Clicking on the 4th Button will open a dialog box as below.

    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.

External JAR: A JAR File in your file system. Use it for test purposes only, otherwise your project would be quite untidy.

Library: Built-in libraries such as JUnit. You don't need to know their location, these come with 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:

Working with Libraries - shared, bundled, releasing, and using 3rd Party SDKs

Where the API is available as source or a Jar, I have found it significantly easier to include the source directly in the application. For example, in this case, rather than include the TwitterAPIME jar, you could include the TwitterAPIME source as a separate project in the application. As well as being easier to build, this can help in debugging or at least understanding issues with the API.

You might also find this sample, and in fact the containing Thread, useful:

Twitter + Facebook Sample Integration

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. 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. Rather than changing jar dependency in every project.

An external Jar is a Jar in a path outh of your Eclipse environment: ie outside of both Eclipse jars and projects generated jars.

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. 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. Later use this library in your project.

Sometimes adding jars directly in the blackberry project might cause some build problems. Here 'sa solution that works (90%):

  1. You have your blackberry project. Now create a new simple Java Project .
  2. Right-click on it > 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. Then OK .
  3. Now go back to your blackberry project and Right-click on it > Properties > Java Build Path and click on the Projects tab, click on Add and select the project you just created and OK.
  4. Now go back and build your Blackberry project.

I hope this help.

如果在Eclipse工作区中添加JAR,请说/ myproject / WebRoot / WEB-INF / lib但是在使用Select Jar弹出窗口时Eclipse不显示/ lib,退出向导并刷新WebRoot(rtClick并执行Refresh或F5):Eclipse仅显示尚未添加到项目中的新库,通常需要先手动刷新。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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