You are viewing the article How to Add JAR to Project Build Path in Eclipse (Java) at Tnhelearning.edu.vn you can quickly access the necessary information in the table of contents of the article below.
wikiHow is a “wiki” site, which means that many of the articles here are written by multiple authors. To create this article, 16 people, some of whom are anonymous, have edited and improved the article over time.
This article has been viewed 7,825 times.
When your Java project requires a JAR (Java Archive) library to run, you need to customize your project to add the libraries to the build path. Fortunately, Eclipse makes this process simple and easy to remember. The build version used in this article is Eclipse Java – Ganymede 3.4.0.
Steps
Add inner JAR (Internal)
- Create a new folder called lib in your project folder. This stands for “libraries” that includes the entire JAR you will use for that project.
{“smallUrl”:”https://www.wikihow.com/images_en/thumb/0/02/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29-Step-1Bullet1.jpg /v4-728px-Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29-Step-1Bullet1.jpg”,”bigUrl”:”https://www.wikihow.com/images/ thumb/0/02/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29-Step-1Bullet1.jpg/v4-728px-Add-JARs-to-Project-Build-Paths-in -Eclipse-%28Java%29-Step-1Bullet1.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw -parser-output”></div>”}
- Copy the JARs you need into lib .
{“smallUrl”:”https://www.wikihow.com/images_en/thumb/3/38/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29-Step-1Bullet2.jpg /v4-728px-Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29-Step-1Bullet2.jpg”,”bigUrl”:”https://www.wikihow.com/images/ thumb/3/38/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29-Step-1Bullet2.jpg/v4-728px-Add-JARs-to-Project-Build-Paths-in -Eclipse-%28Java%29-Step-1Bullet2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw -parser-output”></div>”}
- Refresh your project by right clicking on the project name and selecting Refresh . The lib folder should now appear in Eclipse, with the JAR inside.
{“smallUrl”:”https://www.wikihow.com/images_en/thumb/b/ba/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29-Step-1Bullet3.jpg /v4-728px-Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29-Step-1Bullet3.jpg”,”bigUrl”:”https://www.wikihow.com/images/ thumb/b/ba/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29-Step-1Bullet3.jpg/v4-728px-Add-JARs-to-Project-Build-Paths-in -Eclipse-%28Java%29-Step-1Bullet3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw -parser-output”></div>”}
Method 1
Method 2
Add External JAR (External)
Note: It is better to reference the JAR that is present in your project or another project – This helps you to check all the dependencies in the version control system (version contrp). (You ‘re using a version management system, right?). Use one of the methods below.
Method 1
This is the preferred method because it allows multiple developers of the same project to search for external jars in different locations.
- If you share the project with others, they must also define the variable. They can define it in
Window->Preferences->Java->Build Path->Classpath Variables
Method 2
Note that if you use this method, the external JAR must be in the same location on everyone’s hard drive. This can make it more difficult to share a common project.
Method 3
Note that if you use this method, the external JAR must be in the same location on whoever’s hard drive is working on the project. This can make sharing a joint project more difficult.
Advice
- Every time you add a new file or folder to your project in Eclipse through anything other than Eclipse, you must refresh the affected projects so Eclipse knows where the new files are. Otherwise you may get a compile error or a build path error.
- Even though the internal JARs disappear from lib , they still exist in the filesystem. This is just Eclipse’s way of notifying you that those JARs have been added.
- To be on the safe side, you’ll probably need to create a folder to write your code notes in the text. Here’s how to do it:
- Right-click the .JAR in the Reference Libraries in the package explorer.
- Select the Javadoc tag and type the directory (or URL) containing the text. (Note: Eclipse doesn’t like this and the validation will fail. Don’t worry though, it will work.)
- Select Java Source Attachment and search for the folder or .JAR file containing the source.
wikiHow is a “wiki” site, which means that many of the articles here are written by multiple authors. To create this article, 16 people, some of whom are anonymous, have edited and improved the article over time.
This article has been viewed 7,825 times.
When your Java project requires a JAR (Java Archive) library to run, you need to customize your project to add the libraries to the build path. Fortunately, Eclipse makes this process simple and easy to remember. The build version used in this article is Eclipse Java – Ganymede 3.4.0.
Thank you for reading this post How to Add JAR to Project Build Path in Eclipse (Java) at Tnhelearning.edu.vn You can comment, see more related articles below and hope to help you with interesting information.
Related Search: