Friday, March 4, 2011

Add JARs to Project Build Paths in Eclipse

1. Copy the JARs you'll be using to your project if you haven't done so already. Here's how it's conventionally done:

1. Create a new folder named

lib

in your project folder. This stands for "libraries" and will contain all the JARs you'll be using for that project.

2. Copy the JARs you need to

lib

.

3. Copied JARs to the project.

http://pad2.whstatic.com/skins/common/images/magnify-clip.pngCopied JARs to the project.

Refresh your project by right clicking the project name and selecting Refresh. The

lib

folder will now be visible in Eclipse with the JARs inside.

2. Complete either of the following to finish configuring your build path.

Method 1

1. Expand

lib

in Eclipse and select all the JARs you need.

2. Right click the JARs and navigate to

Build Path

.

3. Select

Add to Build Path

. The JARs will disappear from

lib

and reappear in

Referenced Libraries

.

http://pad2.whstatic.com/images/thumb/9/9a/Adding_Internal_JARs_Short_723.png/300px-Adding_Internal_JARs_Short_723.png

http://pad3.whstatic.com/images/thumb/3/31/Added_JARs_Result_243.png/300px-Added_JARs_Result_243.png

Method 2

1. Right click the project name and navigate to

Build Path

.

2. Select

Configure Build Path...

and the project properties window will appear showing your build path configurations.

http://pad1.whstatic.com/images/thumb/5/5e/Opening_Build_Path_538.png/300px-Opening_Build_Path_538.png

3. Select the

Libraries

tab.

4. Click

Add JARs...

5. Locate and select the JARs you want and click OK. The JARs will now appear in the list of libraries in the build path.

http://pad1.whstatic.com/images/thumb/e/ee/Adding_Internal_JARs_643.png/300px-Adding_Internal_JARs_643.png

6. Click OK to close the properties window. The JARs will now be in

Referenced Libraries

instead of

lib

.

Adding External JARs

Note: It is much better to reference jars that exist in your project or in other projects - this allows you to check in all of your dependencies to your version control system. (You are using version control, right?)

Use one of the following methods.

Method 1

This is the preferred method, as it allows different developers of a common project to locate their external jars in different places.

1. Right click the project name and navigate to

Build Path

.

2. Select

Configure Build Path...

and the project properties window will appear showing your build path configurations.

3. Click

Add Variable...

4. Click

Configure Variables...

5. Click

New...

6. Type a name for the new variable. For example, if these are jars for Tomcat, perhaps call it TOMCAT_JARS

7. Browse to the directory that contains the jar for the path. (You can also select a specific jar file for the variable, if you prefer.)

8. Click

Ok

to define the variable

9. Click

Ok

to close the preferences dialog

10. Select the variable from the list

11. Click

Extend...

12. Select the jar(s) that you want to add to the classpath

13. Click

Ok

to close the extend dialog

14. Click

Ok

to close the new classpath variable dialog

15. Click

Ok

to close the build path setup dialog

If you share the project with someone else, they must also define the variable. They can define it under

Preferences->Java->Build Path->Classpath Variables">Window->Preferences->Java->Build Path->Classpath Variables

Method 2

Note that if you use this method, the external jar will need to be in the same location on the hard drive for anyone who uses this project. This can make sharing a common project more difficult.

1. Right click the project name and navigate to

Build Path

.

2. Select

Add External Archives...

http://pad2.whstatic.com/images/thumb/3/34/Adding_External_JARs_Short_76.png/300px-Adding_External_JARs_Short_76.png

3. Locate and select the JARs you want and click

Open

. The JARs will now appear in

Referenced Libraries

.

Method 3

Note that if you use this method, the external jar will need to be in the same location on the hard drive for anyone who uses this project. This can make sharing a common project more difficult.

1. Right click the project name and navigate to

Build Path

.

2. Select

Configure Build Path...

and the project properties window will appear showing your build path configurations.

3. Select the

Libraries

tab.

4. Click

Add External JARs...

5. Locate and select the JARs you want and click

Open

. The JARs will now appear in the list of libraries in the build path.

http://pad3.whstatic.com/images/thumb/1/10/Adding_External_JARs_6.png/300px-Adding_External_JARs_6.png

6. Click OK to close the properties window. The JARs will now be in

Referenced Libraries

.

123passportphoto is a very easy to use passport photo website that provides six enhanced photos. I have never had an issue while using this ...