How do I set the classpath in NetBeans?
- Right-click your Project.
- Select
Properties
. - On the left-hand side click
Libraries
. - Under
Compile tab
- clickAdd Jar/Folder
button.
Or
- Expand your Project.
- Right-click
Libraries
. - Select
Add Jar/Folder
.
Maven
The Answer by Bhesh Gurung is correct… unless your NetBeans project is Maven based.
Dependency
Under Maven, you add a "dependency". A dependency is a description of a library (its name & version number) you want to use from your code.
Or a dependency could be a description of a library which another library needs ("depends on"). Maven automatically handles this chain, libraries that need other libraries that then need other libraries and so on. For the mathematical-minded, perhaps the phrase "Maven resolves the transitive dependencies" makes sense.
Repository
Maven gets this related-ness information, and the libraries themselves from a Maven repository. A repository is basically an online database and collection of download files (the dependency library).
Easy to Use
Adding a dependency to a Maven-based project is really quite easy. That is the whole point to Maven, to make managing dependent libraries easy and to make building them into your project easy. To get started with adding a dependency, see this Question, Adding dependencies in Maven Netbeans and my Answer with screenshot.