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 – Black Friday 2026 – NPI EA – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

1. Overview

A good IDE is important for developer productivity. IntelliJ is currently one of the leading IDEs and supports many programming languages.

In this tutorial, we’ll start with some of the basic configurations in IntelliJ, focusing on the Java programming language. We’ll also list the most common shortcuts in IntelliJ for boosting developer productivity.

2. Installing IntelliJ

First, we need to download and install IntelliJ for our platform. For the features that we are going to go over, IntelliJ IDEA with or without Ultimate Subscription will do great.

3. Basic Project Configuration in IntelliJ

3.1. Configuring JDK

IntelliJ is written in Java and comes with a packaged JRE for running the IDE.

However, we can configure IntelliJ IDEA to use a different JDK for our projects. It can be configured either globally or per project.

Let’s see how to configure a JDK from the File > Project Structure option:

jdk config

Usually, it will list every installed JDK and allow us to choose the desired one.

Next, we’ll create a new Java project.

3.2. Creating a Java Project

In order to create a new Java project, let’s bring up the New project wizard from File->New->Project:

intellij new project wizard

Next, we’ll select Java in order to create a simple Java project.

Additionally, this window allows us to configure a project-specific JDK if we want to.

Click Create button to create the project.

Now that we have a basic project structure, we can add a Java class by selecting the src folder and then either right-clicking or typing Alt+Insert. We’ll select Java Class from this menu and get a dialog where we can give it a name:

create class

3.3. Configuring Libraries

A Java project usually depends on a lot of external or third-party libraries. And while Maven and Gradle are the typical go-tos for managing this, let’s take a look at how to do this natively in IntelliJ.

Let’s say we want to use the StringUtils API from the commons-lang3 library.

Like the JDK settings, we can also configure libraries at global and project level. Global libraries are shared by all projects. Both global and project specific libraries can be added by accessing the Project Structure dialog (File->Project Structure).

In order to add the library, we must download it first. Normally, the common source for any external library is the Maven Repository. Hence, IntelliJ allows us to download it directly from any pre-configured Maven repository. And of course, if no repository is configured, it will search the Maven Central:

download jar from maven central-1

IntelliJ will now download the commons-lang3.jar into a specified folder. Along with that, it also adds it to the project classpath.

Of course, remember that adding a library this way is IntelliJ-specific and not as portable as more robust options. It’s convenient, though, for simple projects.

In the next section, we’ll use this library and execute a simple Java program.

4. Running or Debugging an Application

4.1. Run/Debug Configurations

Before we run our Java program, let’s add some code to the class we added earlier. We’ll simply use the added library and call StringUtils.reverse() to reverse any text given as a program argument:

System.out.println(StringUtils.reverse(args[0]));

Now, there are 2 approaches for running this main method in IntelliJ. Firstly, we can simply run Ctrl + Shift +F10 or Control + Shift + R/D from the main class. IntelliJ will then create a temporary Run configuration.

However, since we have to pass a String to our StringReversal application as a program argument (the args[0] part), a temporary run configuration won’t work.

So, we can create a permanent Run/Debug Configuration.

We’ll do that using the “Edit Configurations” window from the Run Navigation bar (Run->Edit Configurations):

sample run configuration

Here, we specify the name of our class to run in Main Class. It needs to have a main method for this to work.

We’ll also pass a String – “baeldung“, in this case – as a Program Argument to our application.

And, while we won’t demo this here, we can also configure JVM options and environment variables, too, for our application.

Contrary to temporary run configurations, IntelliJ saves this configuration and allows us to execute it any time with a click of a button.

4.2. Debugging a Java Application

IntelliJ has great support for debugging many languages. Let’s debug our String Reversal utility as an example.

As with most IDEs, we can add a breakpoint on any line of our class from the editor by clicking on the side panel:

sample debug point

Now, we can debug the class by clicking on the debug icon from the Run/Debug configuration.

In this case, the program is suspended at line 7 as shown above, allowing us to inspect the thread stack, inspect variables or even evaluate expressions (Alt+F8 or Option/Alt + F8).

At this point, we can either Step Into (F7) the StringUtils.reverse() method, Step Over (F8) the line or Resume Program (F9), meaning run until either the next breakpoint or until the end of the application.

Usually, most IDEs allow the users to mark a line in a Java class as a breakpoint like we just used. In addition, IntelliJ allows us to configure more than just Line breakpoints. We can also do:

  • Temporary Breakpoint – A line breakpoint which is executed only once
  • Exception Breakpoint – A breakpoint on any exception class in Java. The debugger will pause when that exception is about to be thrown
  • Method Breakpoint – One that executes when entering or exiting a method
  • Field Breakpoint – And one that executes when a field is modified

A breakpoint can have conditional logic, too.

We can view and configure all the breakpoints in a project in the Breakpoints dialog Run->View Breakpoints (Ctrl+Shift+F8 or Cmd+Shift+F8).

4.3. Building Artifacts

Now that we’ve tested, debugged and fixed all the issues, we are ready to ship our application. Therefore, we need to create deployable binaries for our application.

We can create deployable .jar binaries in IntelliJ automatically. 

First, in the Project Structure (Ctrl+Alt+Shift+S or Cmd+;), we need to declare a new artifact.

We select “Artifacts”  and then click the plus button.

Next, we select a JAR artifact and also add dependencies in the JAR:

jar artifact

 

Next, we’ll go back to our Run/Debug Configuration dialog.

There, we need to add a Build Artifact task in the Before Launch window. As a result, a new executable jar is created for our application every time we execute our Run/Debug configuration.

Again, building artifacts is not IDE-agnostic. This mechanism is specific to IntelliJ. A build management tool could be a better approach, similar to what we discussed for dependency management.

5. Common Shortcuts in IntelliJ

The shortcuts are really useful in boosting developers productivity. The following is a quick cheat sheet for the most common ones.

5.1. Navigation

  • Search Class – Ctrl + N / Cmd + O
  • Search All files – Double Shift
  • Recent Files – Ctrl + E / Cmd + E
  • Switch between files – Ctrl + Tab / Cmd + Tab
  • Type Hierarchy – Ctrl + H / Control + H
  • Call Hierarchy – Ctrl + Alt + H /  Control + Alt+ H
  • File structure popup – Ctrl + F12 / Cmd + F12 (lists all methods and fields)
  • Go to declaration – Ctrl + B / Cmd + b
  • Go to implementations – Ctrl + Alt + B / Cmd + Alt+ B
  • Show Project Structure – Ctrl + Alt + Shift + S / Cmd + ;

5.2. Editor

  • Code Completion – Ctrl + Space / Control + Space
  • Method parameter info – Ctrl + P / Cmd + P
  • Method/Class documentation info – Ctrl + Q / Control + J
  • Reformat Code – Ctrl + Alt + L / Cmd + Alt + L
  • Optimize imports – Ctrl + Alt + O / Control + Alt + O
  • Duplicate line – Ctrl + D / Cmd + D
  • Delete line – Ctrl + Y / Cmd + Delete
  • Code selection – Ctrl + W / Alt + Up
  • Show quick actions – Alt + Enter / Alt + Return
  • System.out.println – sout + Ctrl + Enter / sout + Control + Space
  • public static void main – psvm + Ctrl + Enter / psvm + Control + Space
  • System.out.println for a method’s return value – methodName().sout [Enter]
  • Assign method’s return value to local variable – methodName().var [Enter]

5.3. Refactoring

  • Rename class/method – Shift + F6
  • Extract Method – Ctrl + Alt + M / Cmd + Alt + M
  • Extract variable – Ctrl + Alt + V / Cmd + Alt + V
  • Extract field – Ctrl + Alt + F / Cmd + Alt + F
  • Extract constant – Ctrl + Alt + C / Cmd + Alt + C
  • Extract parameter – Ctrl + Alt + P / Cmd + Alt + P

6. Conclusion

In this article, we looked at some basic configurations in IntelliJ.

As an example, we created a Java project, added libraries, debugged it, and created an artifact, all in IntelliJ.

Lastly, we looked at shortcuts for some common actions.

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.

Course – Black Friday 2026 – NPI EA – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW