Choosing a Java IDE: IntelliJ IDEA vs Eclipse vs VS Code
Introduction
You can write Java in any text editor and compile it from the command line, but almost every Java developer uses an IDE (Integrated Development Environment). This tutorial compares the three most popular Java IDEs - IntelliJ IDEA, Eclipse and Visual Studio Code - and helps you choose one. We will start with what an IDE does for you. We will then look at each of the three IDEs, compare them side by side, and see how to create and run a first program in each. Lastly, we will look at the keyboard shortcuts which save the most time.
(Note - An IDE needs a JDK to compile and run your code. If you have not installed one yet, follow How to Install the JDK and Set JAVA_HOME and PATHClick to read tutorial: How to Install the JDK and Set JAVA_HOME and PATH first.) What does an IDE do for you? An IDE combines an editor, the compiler, a debugger and many other tools into one program. For Java, a good IDE gives you -
IntelliJ IDEA has a free tier which covers everything you need for core Java - which is all of this Java Fundamentals series - and a paid Ultimate tier which adds support for enterprise frameworks such as Spring and Jakarta EE, databases and web development. It runs on Windows, macOS and Linux, and can even download a JDK for you when you create a project. Android Studio, Google's IDE for Android apps, is also built on IntelliJ IDEA.
Eclipse
Eclipse is a free, open-source IDE from the Eclipse Foundation, and was the most popular Java IDE for many years. It is still widely used in companies, especially on older projects. Download the package named Eclipse IDE for Java Developers.
Eclipse organizes your projects into a workspace folder, and can be extended with thousands of plugins. It has its own incremental Java compiler, so it shows errors immediately as you type. Many companies build their own internal tools on top of Eclipse. Visual Studio Code Visual Studio Code (VS Code) is a free, lightweight code editor from Microsoft which supports many languages. It becomes a capable Java IDE once you install Microsoft's Extension Pack for Java, which adds Java language support, debugging, testing, and Maven and Gradle support.
VS Code starts quickly and uses less memory than a full IDE. It is a good choice if you already use it for other languages such as JavaScript or Python, or if you want a simple editor while learning. For large Java projects, its refactoring and analysis are not as deep as IntelliJ IDEA's.
Note - Apache NetBeans is another free, open-source Java IDE, and a simple, beginner-friendly option which works well out of the box. IntelliJ IDEA vs Eclipse vs VS Code - comparison
Our recommendation: if you are starting out, use IntelliJ IDEA. It gives the best help while you learn, and it is what most Java teams use. All three are good, however, and the Java you learn is exactly the same in each.
Creating and running your first program
The steps are similar in all three IDEs -
OUTPUT in the IDE's Run window
Explanation of the code
(Note - An IDE needs a JDK to compile and run your code. If you have not installed one yet, follow How to Install the JDK and Set JAVA_HOME and PATHClick to read tutorial: How to Install the JDK and Set JAVA_HOME and PATH first.) What does an IDE do for you? An IDE combines an editor, the compiler, a debugger and many other tools into one program. For Java, a good IDE gives you -
- Code completion: Suggests class names, methods and variables as you type, so you do not have to remember every method of every class.
- Errors as you type: Compile errors are underlined in red while you write, instead of when you run
javac, and many come with one-click quick fixes. - One-click run and debug: Compile and run a program with a single click. The debugger lets you pause a running program, step through it line by line, and look at the values of variables.
- Refactoring: Rename a class or method, or move code around, and the IDE updates every place that uses it.
- Project and build tool support: Works with Maven and Gradle projects, version control such as Git, and unit tests.
IntelliJ IDEA has a free tier which covers everything you need for core Java - which is all of this Java Fundamentals series - and a paid Ultimate tier which adds support for enterprise frameworks such as Spring and Jakarta EE, databases and web development. It runs on Windows, macOS and Linux, and can even download a JDK for you when you create a project. Android Studio, Google's IDE for Android apps, is also built on IntelliJ IDEA.
Eclipse organizes your projects into a workspace folder, and can be extended with thousands of plugins. It has its own incremental Java compiler, so it shows errors immediately as you type. Many companies build their own internal tools on top of Eclipse. Visual Studio Code Visual Studio Code (VS Code) is a free, lightweight code editor from Microsoft which supports many languages. It becomes a capable Java IDE once you install Microsoft's Extension Pack for Java, which adds Java language support, debugging, testing, and Maven and Gradle support.
VS Code starts quickly and uses less memory than a full IDE. It is a good choice if you already use it for other languages such as JavaScript or Python, or if you want a simple editor while learning. For large Java projects, its refactoring and analysis are not as deep as IntelliJ IDEA's.
Note - Apache NetBeans is another free, open-source Java IDE, and a simple, beginner-friendly option which works well out of the box. IntelliJ IDEA vs Eclipse vs VS Code - comparison
| IntelliJ IDEA | Eclipse | VS Code | |
| Made by | JetBrains | Eclipse Foundation | Microsoft |
| Cost | Free tier for core Java; paid Ultimate tier | Free, open source | Free; Java support through free extensions |
| Type | Full Java IDE | Full Java IDE | Lightweight editor with Java extensions |
| Code completion and analysis | Excellent | Very good | Good |
| Refactoring | Excellent | Very good | Basic to good |
| Speed and memory | Heavier | Medium | Lightest |
| Best for | Most Java developers, from beginners to large projects | Existing Eclipse-based teams and plugins | Developers who work in several languages |
Our recommendation: if you are starting out, use IntelliJ IDEA. It gives the best help while you learn, and it is what most Java teams use. All three are good, however, and the Java you learn is exactly the same in each.
- IntelliJ IDEA: Choose File > New > Project, select Java, pick your JDK, and click Create. Right-click the
srcfolder, choose New > Java Class, and name itFirstProgram. Click the green run arrow next tomain()to run it. - Eclipse: Choose File > New > Java Project, enter a name and click Finish. Right-click the
srcfolder, choose New > Class, enterFirstProgram, tick public static void main(String[] args) and click Finish. Run it with Run > Run As > Java Application. - VS Code: Open a folder, create a file named
FirstProgram.java, and type the code. Click Run above themain()method, or pressF5.
sum grow.
A first program to run in your IDE
//FirstProgram.java
public class FirstProgram {
public static void main(String[] args) {
int sum = 0;
for (int i = 1; i <= 10; i++) {
sum = sum + i;
}
System.out.println("My first program in an IDE!");
System.out.println("Sum of 1 to 10 = " + sum);
}
}
My first program in an IDE! Sum of 1 to 10 = 55
- The
forloop runs ten times, adding each number from 1 to 10 tosum. Loops are covered in the for loop tutorialClick to read tutorial: Java for Loop Tutorial with Examples. - To debug it, click in the left margin next to the line
sum = sum + i;to set a breakpoint, then run the program in debug mode. The program pauses at that line each time round the loop, and the IDE shows the current values ofiandsum.
Cmd instead of Ctrl in most of them.- IntelliJ IDEA: Type
psvmormainand pressTabto create amain()method, andsoutthenTabforSystem.out.println().Ctrl+Spacecompletes code,Alt+Entershows quick fixes, andShift+F10runs the program. - Eclipse: Type
mainorsysoutand pressCtrl+Spacefor the same templates.Ctrl+1shows quick fixes,Ctrl+Shift+Fformats the code, andCtrl+F11runs the program. - VS Code: Type
mainorsysoutand choose the suggestion.Ctrl+Shift+Popens the command palette,F5runs with the debugger, andCtrl+F5runs without it.
Java Fundamentals Tutorials
How to Install the JDK and Set JAVA_HOME and PATHClick to read tutorial: How to Install the JDK and Set JAVA_HOME and PATH Java Hello World Program Explained Line by LineClick to read tutorial: Java Hello World Program Explained Line by Line What is Java? History, Features, Editions and UsesClick to read tutorial: What is Java? History, Features, Editions and Uses JDK vs JRE vs JVM - Differences Explained with ExamplesClick to read tutorial: JDK vs JRE vs JVM - Differences Explained with Examples Compiling and Running Java Programs with javac and javaClick to read tutorial: Compiling and Running Java Programs with javac and java How Java Code Runs: Bytecode, Class Loader and JITClick to read tutorial: How Java Code Runs: Bytecode, Class Loader and JIT JShell Tutorial: Java's Interactive REPL with ExamplesClick to read tutorial: JShell Tutorial: Java's Interactive REPL with Examples
How to Install the JDK and Set JAVA_HOME and PATHClick to read tutorial: How to Install the JDK and Set JAVA_HOME and PATH Java Hello World Program Explained Line by LineClick to read tutorial: Java Hello World Program Explained Line by Line What is Java? History, Features, Editions and UsesClick to read tutorial: What is Java? History, Features, Editions and Uses JDK vs JRE vs JVM - Differences Explained with ExamplesClick to read tutorial: JDK vs JRE vs JVM - Differences Explained with Examples Compiling and Running Java Programs with javac and javaClick to read tutorial: Compiling and Running Java Programs with javac and java How Java Code Runs: Bytecode, Class Loader and JITClick to read tutorial: How Java Code Runs: Bytecode, Class Loader and JIT JShell Tutorial: Java's Interactive REPL with ExamplesClick to read tutorial: JShell Tutorial: Java's Interactive REPL with Examples