Eclipse IDE- Add jar? Add External jar? Add Library?
Asked Answered
P

7

34

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 ?

Pantsuit answered 13/12, 2011 at 8:49 Comment(3)
See the Eclipse documentation hereTrunks
Thanks for the documentation link...Pantsuit
@whoever_downvoted_this_question - It's nasty to downvote a question just because you feel that it's obvious where the answer lies in some incredibly dense documentation. It's like saying "All you have to do is know to look in Wizards and Dialogs > Create New Elements > New Java Project Wizard > Java Build Path Page. What are you, a Vogon? I say +1 for asking a simple question. Thanks Chethan for asking, thanks Manish for posting the link. This post ranks high on Google and it was very helpful to me.Cosh
C
45

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 e.g. 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".

Cumulostratus answered 21/5, 2012 at 3:56 Comment(1)
BTW, a user library is a set of JAR files.Uncontrollable
B
13

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.

Basting answered 13/12, 2011 at 9:31 Comment(0)
B
2

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

Brushoff answered 13/1, 2014 at 10:10 Comment(0)
C
2

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.

Commerce answered 13/1, 2014 at 16:11 Comment(0)
C
2

An external Jar is a Jar in a path outh of your Eclipse environment: i.e. 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.

Caveator answered 14/1, 2014 at 23:6 Comment(0)
F
1

Sometimes adding jars directly in the blackberry project might cause some build problems. Here 's a 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.

Frowst answered 13/12, 2011 at 9:10 Comment(0)
B
0

If you add the JAR within the Eclipse workspace, say /myproject/WebRoot/WEB-INF/lib but Eclipse does not display the /lib when using the Select Jar pop-up, exit the wizard and refresh WebRoot (rtClick and take Refresh or F5): Eclipse only shows new libraries not already added to the project and usually needs a manual refresh first.

Budgie answered 6/2, 2015 at 19:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.