Are you ready to start learning Java 21? Before writing your first line of code, you need to set up your development environment. Don’t worry—it’s not hard! This guide will help you step by step in setting up Java 21 development environment.

Let’s get started!
✅ Step 1: Install Java 21 (JDK)
The JDK (Java Development Kit) is what you need to run and build Java programs.
🔽 Download the JDK
Pick one of these trusted sources:
Choose the version for your operating system (Windows, Mac, Linux), then install it.
I am using a Windows system and work on the Open JDK
✅ Check if it’s working
After installing, open your terminal (Command Prompt on Windows or Terminal on Mac/Linux), and type:
1 |
java -version |
✅ Step 2: Choose an IDE
An IDE (Integrated Development Environment) is an app that helps you write code easily. It gives you features like suggestions, highlighting, and debugging.
💡 Best IDEs for Java
- IntelliJ IDEA – beginner-friendly, powerful
- VS Code – lightweight and fast. Also has inbuilt Copilot plugins.
- Eclipse – great for big projects
Install any one of them. I use Eclipse and some time VS Code.
✅ Step 3: Set Up a Build Tool (Maven or Gradle)
Java developers use build tools to manage projects, add libraries, and compile code.
You can choose Maven or Gradle—both are good.
🛠️ Maven (Beginner-Friendly)
In Maven, we use a file called pom.xml
to manage the project.
Here’s how you tell Maven to use Java 21:
1 2 3 4 5 |
<properties> <maven.compiler.source>21</maven.compiler.source> <maven.compiler.target>21</maven.compiler.target> </properties> |
You can install Maven from https://maven.apache.org/ . Or if you are using IDE and executing your classes inside them, they already have built in Maven plugins.
⚙️ Gradle (Slightly Advanced)
In Gradle, the config goes into a build.gradle
file:
1 2 3 4 5 |
java { toolchain { languageVersion = JavaLanguageVersion.of(21) } } |
Gradle is more flexible and modern but takes a bit more time to learn. So as a beginner, you should start with Maven.
✅ Step 4: Write and Run Your First Java Program
Let’s write a simple program to test your setup!
File: TestFirstJava.java
1 2 3 4 5 |
public class TestFirstJava { public static void main(String[] args) { System.out.println("Hello from Java 21!"); } } |
Compile it and run it
1 2 3 |
javac Main.java java Main |
🧠 Quick Recap
Tool | What It Does |
---|---|
JDK 21 | Runs and compiles Java programs |
IDE | Helps you write and debug code |
Maven | Manages libraries and builds code |
Gradle | Same as Maven, but more flexible |
Hope this guide for setting up Java 21 development environment was helpful !!!