How can I include other downloaded packages in eclipse - java

I've found Javaluator, and it looks like something I'd like to use in my java project. When I go to the downloads page, there are 2 options, maven or a zip folder containing lots of .JAR files. I'm very new to eclipse and java programming as a whole, and was wondering how I could sort of "Import" or include them in my project. Any help appriciated, thanks!

Follow the below steps to add externally downloaded java packages(JAR) file to an Eclipse Project.
Right click on your project.
Select Build Path.
Click on Configure Build Path.
Click on Libraries and select Add External JARs.
Select the jar file from the required folder.
Click and Apply and Ok.
All done.

Related

Eclipse add external jars doesn't work to add them as Referenced libraries

I'm currently doing this tutorial on Hibernate over here http://www.javatpoint.com/example-to-create-hibernate-application-in-eclipse-ide and I downloaded the hibernate.zip and oracle.jar files, tried to add them to the project through right clicking on the project -> build path -> configure build path -> add external jars and selecting the jars, but they are not getting imported in a "Referenced library", they just appear as stand alone .jar files that don't to anything and can't be referenced to.
How can I make them "go" into the Referenced Libraries? That folder isn't even created when I import the jar files.
Thanks!
You should use Maven for handling your dependencies and let Eclipse & Maven together take care of downloading and organizing your dependencies. You won't even need to download the jar files manually anymore.
This is the basic usage of Maven with Eclipse:
http://www.tech-recipes.com/rx/39279/create-a-new-maven-project-in-eclipse/
In case you're totally new to Maven, i'm happy to provide further help via comments.
I suppose your Eclipse perspective is selected "Resource", not "Java" or "Java EE".
After you change the perspective to "Java", you will see the Referenced Libraries.
Check this Option : Right click Project >> Show In >> Project Explorer

Setting up MySQL connector in Java [duplicate]

How do I import a jar in Eclipse?
You can add a jar in Eclipse by right-clicking on the Project → Build Path → Configure Build Path. Under Libraries tab, click Add Jars or Add External JARs and give the Jar. A quick demo here.
The above solution is obviously a "Quick" one. However, if you are working on a project where you need to commit files to the source control repository, I would recommend adding Jar files to a dedicated library folder within your source control repository and referencing few or all of them as mentioned above.
Adding external Jar is not smart in case you want to change the project location in filesystem.
The best way is to add the jar to build path so your project will compile if exported:
Create a folder called lib in your project folder.
copy to this folder all the jar files you need.
Refresh your project in eclipse.
Select all the jar files, then right click on one of them and select Build Path -> Add to Build Path
Two choices:
1/ From the project:
2/ If you have already other jar imported, from the directory "References Libraries":
Both will lead you to this screen where you can mange your libraries:
Here are the steps:
click File > Import. The Import window opens.
Under Select an import source, click J2EE > App Client JAR file.
Click Next.
In the Application Client file field, enter the location and name of the application client JAR file that you want to import. You can click the Browse button to select the JAR file from the file system.
In the Application Client project field, type a new project name or select an application client project from the drop-down list. If you type a new name in this field, the application client project will be created based on the version of the application client JAR file, and it will use the default location.
In the Target runtime drop-down list, select the application server that you want to target for your development. This selection affects the run time settings by modifying the class path entries for the project.
If you want to add the new module to an enterprise application project, select the Add project to an EAR check box and then select an existing enterprise application project from the list or create a new one by clicking New.
Note: If you type a new enterprise application project name, the enterprise application project will be created in the default location with the lowest compatible J2EE version based on the version of the project being created. If you want to specify a different version or a different location for the enterprise application, you must use the New Enterprise Application Project wizard.
Click Finish to import the application client JAR file.
Just a comment on importing jars into Eclipse (plug-in development) projects:
In case you are developing Eclipse plug-ins, it makes sense to use Eclipse's native bundling mechanism instead of just importing the jar into a plug-in project. Eclipse (or better its underlying OSGi runtime, Equinox) uses so-called bundles which contain some more information than plain jars (e.g., version infos, dependencies to other bundles, exported packages; see the MANIFEST.MF file). Because of this information, OSGi bundles can be dynamically loaded/unloaded and there is automatic dependency resolution available in an OSGi/Eclipse runtime. Hence, using OSGi bundles instead of plain jars (contained inside another OSGi bundle) has some advantages.
(BTW: Eclipse plug-ins are the same thing as OSGi bundles.)
There is a good chance that somebody already bundled a certain (3rd party) library as an OSGi bundle. You might want to take a look at the following bundle repositories:
http://www.springsource.com/repository/app/
http://download.eclipse.org/tools/orbit/downloads/
http://www.osgi.org/Repository/HomePage
Eclipse -> Preferences -> Java -> Build Path -> User Libraries -> New(Name it) -> Add external Jars
(I recommend dragging your new libraries into the eclipse folder before any of these steps to keep everything together, that way if you reinstall Eclipse or your OS you won't have to rwlink anything except the JDK) Now select the jar files you want. Click OK.
Right click on your project and choose Build Path -> Add Library
FYI just code and then right click and Source->Organize Imports
Jar File in the system path is:
C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar
ojdbc14.jar(it's jar file)
To import jar file in your Eclipse IDE, follow the steps given below.
Right-click on your project
Select Build Path
Click on Configure Build Path
Click on Libraries, select Modulepath and select Add External JARs
Select the jar file from the required folder
Click and Apply and Ok
first of all you will go to your project what you are created
and next right click in your mouse and select properties in the bottom
and select build in path in the left corner and add external jar file add click apply .that's it
In eclipse I included a compressed jar file i.e. zip file. Eclipse allowed me to add this zip file as an external jar but when I tried to access the classes in the jar they weren't showing up.
After a lot of trial and error I found that using a zip format doesn't work. When I added a jar file then it worked for me.
Right Click on the Project.
Click on Build Path.
Click On Configure Build Path.
Under Libraries, Click on Add Jar or Add External Jar.
If you are having a trouble on udemy course of chad on springboot for the importing the jar. Then follow these steps.
Right click on the project.
You will see a option of Build Path, click on it.
You will have a option of Configure Build path, click on it.
Go to libraries.
Then go to the place where you have a jar files make them into a new folder and upload on a new place.
Then click on Add External Jars, you will surely be able to upload it which will help on classpathxmlapplicationcontext as well.
Thank you.

Eclipse doesn't find some libraries when using "Add JARs", does find them if using "Add external JARs"

I'm trying to add some libraries to my Java project. My IDE is Eclipse. Visiting
Project Properties -> Java Build Path -> Libraries
enables me to add libraries to my project. If I'm using Add External JARs, I can find all of my libraries (screenshot below).
However, if I'm trying to do the same while using Add JARs, I get a completely different screen (the library listed isn't even there!):
I'm 100% sure that I'm browsing the correct directories. It seems like there's a cache problem with Eclipse or something like that.
I'm appreciating all suggestions on how to solve this problem. Perhaps a workspace-wide settings reset might be in place?
'Add Jar' -> Adds the source of a jar from your workspace
'Add External jar' -> Adds an external .jar or .zip file (something that is not found in your workspace)
'Add Library' -> Adds installed libraries found on your system or in Eclipse
With Add Jars option you are able to add all the jars which are there in present workspace
With Add External Jars you are able to add the jars from the file system.

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 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".
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: 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.
Sometimes adding jars directly in the blackberry project might cause some build problems. Here 's a solution that works (90%):
You have your blackberry project. Now create a new simple Java Project.
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.
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.
Now go back and build your Blackberry project.
I hope this help.
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.

How Can I Add the Apache POI Library in and Eclipse Project?

I download the Apache POI from apache.org but don't know how use it with one of my existing project in Eclipse.
There are several ways, some good, some bad...
Add external Jar - as jjnguy says will work. However, not a good option...
The problem is that if you share your project with someone else and they have the jar in a different spot, they'll get build path errors
Add variable - similar to add external jar, but much more flexible. You can define a classpath variable (under Java prefs) that represents the dir containing jar. In your project, when you add variable, you choose the var you defined and press "extend" to specify the actual jar. As long as you and other developers of your project define the variable, you can have the jar in different spots if you like
Add the jar to your project - create a dir in your project (optional, maybe call it lib) and import the jar into it using File->Import or if your OS supports, drag it as an icon into the folder (On windows I open an explorer window and drag it from there into the folder in eclipse). Then, right-click the jar and select Build-Path->Add to build path.
Add the jar in a separate project and reference it. Add the jar as mentioned in the last bullet to a separate project for that jar. Choose Build-Path->Configure Build path from the project. Go to the "order and export" tab and make sure the jar is checked. Now you can configure your project to reference the new project. This makes things more modular.
Create a user library - under Java prefs you can define a "user library" that contains the jar. This is somewhat similar to a classpath variable, but can reference multiple jars and you only have to add it once to the project.
Create a classpath container plugin. This is more complex, but is a nice option if you are providing a set of plugins for folks. A classpath container can be added like a library to a project and it can manage the jars, even searching for them if you want it to.
You can find the option to add external jars to a project in: Project > Properties > Java Build Path > Libraries tab.
Click on 'Add External Jar' and find where you have the POI library.

Categories

Resources