eBook – Guide Spring Cloud – NPI EA (cat=Spring Cloud)
announcement - icon

Let's get started with a Microservice Architecture with Spring Cloud:

>> Join Pro and download the eBook

eBook – Mockito – NPI EA (tag = Mockito)
announcement - icon

Mocking is an essential part of unit testing, and the Mockito library makes it easy to write clean and intuitive unit tests for your Java code.

Get started with mocking and improve your application tests using our Mockito guide:

Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Reactive – NPI EA (cat=Reactive)
announcement - icon

Spring 5 added support for reactive programming with the Spring WebFlux module, which has been improved upon ever since. Get started with the Reactor project basics and reactive programming in Spring Boot:

>> Join Pro and download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Jackson – NPI EA (cat=Jackson)
announcement - icon

Do JSON right with Jackson

Download the E-book

eBook – HTTP Client – NPI EA (cat=Http Client-Side)
announcement - icon

Get the most out of the Apache HTTP Client

Download the E-book

eBook – Maven – NPI EA (cat = Maven)
announcement - icon

Get Started with Apache Maven:

Download the E-book

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

eBook – RwS – NPI EA (cat=Spring MVC)
announcement - icon

Building a REST API with Spring?

Download the E-book

Course – LS – NPI EA (cat=Jackson)
announcement - icon

Get started with Spring and Spring Boot, through the Learn Spring course:

>> LEARN SPRING
Course – RWSB – NPI EA (cat=REST)
announcement - icon

Explore Spring Boot 3 and Spring 6 in-depth through building a full REST API with the framework:

>> The New “REST With Spring Boot”

Course – LSS – NPI EA (cat=Spring Security)
announcement - icon

Yes, Spring Security can be complex, from the more advanced functionality within the Core to the deep OAuth support in the framework.

I built the security material as two full courses - Core and OAuth, to get practical with these more complex scenarios. We explore when and how to use each feature and code through it on the backing project.

You can explore the course here:

>> Learn Spring Security

Course – LSD – NPI EA (tag=Spring Data JPA)
announcement - icon

Spring Data JPA is a great way to handle the complexity of JPA with the powerful simplicity of Spring Boot.

Get started with Spring Data JPA through the guided reference course:

>> CHECK OUT THE COURSE

Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – LJB – NPI EA (cat = Core Java)
announcement - icon

Code your way through and build up a solid, practical foundation of Java:

>> Learn Java Basics

1. Introduction

IntelliJ IDEA is a widely used IDE for Java development, available in free and paid versions. In Java projects, JAR files contain reusable code and resources, making it easier to use external libraries.

We need to add JAR files to the classpath in IntelliJ IDEA to work with tools like Apache POI or JDBC drivers. This enables our project to recognize them during coding and execution.

In this tutorial, we’ll explore the steps to add an external JAR file to an IntelliJ IDEA project.

2. Why Add an External JAR File to IntelliJ IDEA?

Adding an external JAR file in our IntelliJ IDEA project enables us to use third-party libraries. These libraries provide extra features that Java doesn’t include by default. For example, Apache Commons Collections offers advanced data structures, Jackson helps with JSON processing, and MySQL Connector enables database connections.

By adding a JAR file, we can use these features in our project without writing the code manually. This is important for integrating external APIs, frameworks, and tools. IntelliJ IDEA makes sure our project recognizes these files so our code runs without errors.

3. Adding an External JAR File to the IntelliJ IDEA Project

To add an external JAR file to the IntelliJ project, first, we need to download it. To do this, we can visit a reliable source like Maven Repository or the library’s official website. Then, we can search for the required library and download the JAR file for our project.

After downloading a JAR file, we create a new IntelliJ IDEA project named baeldung:

create new intellij project

We navigate to the File section and then click on the Project Structure to open it:

open project structure

In the left panel, we go to Modules, select our module, click the Dependencies tab, and then press the + button to select an external JAR file:

select jars or directories

We choose JARs or Directories from the available options, locate the downloaded JAR file, and select it to add it to our project:

select the desired jar file

Finally, we click the OK button to add the commons-collections4-4.5.0-M3.jar file, in this case, to our IntelliJ IDEA project:

add the selected jar file

To verify the external JAR file inclusion, we can expand the External Libraries section in the Project view. If the JAR file appears there, it has been successfully added:

verify jar file

Once a JAR file is successfully added to our IntelliJ IDEA project, we can use any classes and methods it provides in our code.

3.1. Using External JAR File to Create a Simple Java Program

Let’s create a simple Java program that uses an external JAR file commons-collections4 to demonstrate the functionality of MultiValuedMap for storing multiple values under a single key.

First, we import MultiValuedMap and ArrayListValuedHashMap from Apache Commons Collections to handle multiple values per key:

import org.apache.commons.collections4.MultiValuedMap;
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;

Also, let’s define a test to check how MultiValuedMap from Apache Commons Collections handles multiple values for a single key:

@Test
void givenMultiValuedMap_whenAddingEntries_thenCanRetrieveThem() {
    MultiValuedMap<Integer, String> authorMap = new ArrayListValuedHashMap<>();

    // Adding multiple names for a single author ID
    authorMap.put(101, "Anees Asghar");
    authorMap.put(101, "A.A.");
    authorMap.put(102, "John Smith");
    authorMap.put(102, "J.S.");

    // Verify values for author ID 101
    Collection<String> names101 = authorMap.get(101);
    assertEquals(2, names101.size());
    assertTrue(names101.contains("Anees Asghar"));
    assertTrue(names101.contains("A.A."));

    // Verify values for author ID 102
    Collection<String> names102 = authorMap.get(102);
    assertEquals(2, names102.size());
    assertTrue(names102.contains("John Smith"));
    assertTrue(names102.contains("J.S."));

     // Verify that an unknown author ID returns an empty collection
    assertTrue(authorMap.get(103).isEmpty());
}

First, we initialize an ArrayListValuedHashMap and add multiple names for two author IDs (101 and 102).

Then, we verify that each ID correctly maps to the expected number of names and contains specific values. Finally, we check that querying a non-existent ID (103) returns an empty collection to ensure that the map behaves as expected.

If the JAR isn’t properly added, IntelliJ throws an error like “Cannot resolve symbol commons“:

cannot resolve symbol error

However, if IntelliJ IDEA recognizes the commons-collections4 JAR, the program compiles and runs successfully.

4. Conclusion

In this article, we explored steps to add an external JAR file to an IntelliJ IDEA project.

We can add a JAR file to the project’s classpath through the Project Structure > Modules > Dependencies section. Then, we can expand the External Libraries section in the Project view to verify the JAR file inclusion in our IntelliJ project.

Adding an external JAR file to an IntelliJ IDEA project lets us use extra features from third-party libraries that Java doesn’t include by default. Moreover, it helps us add tools like database connectors, logging systems, or utility functions, which makes our project more powerful.

Baeldung Pro – NPI EA (cat = Baeldung)
announcement - icon

Baeldung Pro comes with both absolutely No-Ads as well as finally with Dark Mode, for a clean learning experience:

>> Explore a clean Baeldung

Once the early-adopter seats are all used, the price will go up and stay at $33/year.

eBook – HTTP Client – NPI EA (cat=HTTP Client-Side)
announcement - icon

The Apache HTTP Client is a very robust library, suitable for both simple and advanced use cases when testing HTTP endpoints. Check out our guide covering basic request and response handling, as well as security, cookies, timeouts, and more:

>> Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

Course – LS – NPI EA (cat=REST)

announcement - icon

Get started with Spring Boot and with core Spring, through the Learn Spring course:

>> CHECK OUT THE COURSE

Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

eBook Jackson – NPI EA – 3 (cat = Jackson)