Java IDEs
An IDE (Integrated Development Environment) combines a code editor, compiler, debugger, build-tool integration, and project management in one application. Java can be written in any text editor and compiled with javac, but Java's static typing gives IDEs complete knowledge of your code, so a Java IDE can do far more than highlight syntax: it understands every type, method, and reference in the project.
What an IDE Does for Java
| Feature | What it means in practice |
|---|---|
| Error highlighting as you type | Type mismatches, missing imports, and undefined methods are underlined before you compile |
| Code completion | Typing name. lists every method available on a String, with parameter types |
| Automatic imports | Using List offers to add import java.util.List; |
| Navigation | Jump to where a class or method is defined; list every place it is used |
| Refactoring | Rename a method and every call across the project updates safely; extract code into a new method |
| Debugger | Pause at a breakpoint, inspect variables, step line by line |
| Build-tool integration | Opens Maven and Gradle projects, downloads dependencies, runs tests |
| Code generation | Generates constructors, getters, equals, hashCode, and toString |
Refactoring is where an IDE is most valuable. Renaming a method by find-and-replace in a text editor also renames unrelated methods and strings with the same name. An IDE renames exactly the references to that method, because it resolves every reference through the type system.
The Main Java IDEs
IntelliJ IDEA (JetBrains)
The most widely used Java IDE. Known for strong code analysis, refactoring, and smart completion. Its free edition covers everything in this tutorial; paid features add support for enterprise frameworks, databases, and web tooling. JetBrains has restructured its editions over time, so check jetbrains.com for the current free and paid options.
- Can download and manage JDKs from inside the IDE (File → Project Structure → SDKs).
- Built-in Maven and Gradle support.
- Android Studio, Google's official Android IDE, is built on IntelliJ IDEA.
Visual Studio Code with the Extension Pack for Java
VS Code is a lightweight, general-purpose editor. Java support comes from Microsoft's Extension Pack for Java, which bundles language support (powered by the Eclipse JDT language server), a debugger, a test runner, Maven integration, and a project manager.
- Good choice if you already use VS Code for other languages.
- Lighter on memory than full IDEs; suited to small and medium projects.
- Single
.javafiles can be run directly with a Run button.
Eclipse IDE
A long-established, free, open-source IDE from the Eclipse Foundation. Download the Eclipse IDE for Java Developers package.
- Highly extensible through plugins.
- Uses its own incremental compiler, which reports errors as you type even in very large codebases.
- Common in enterprises and universities.
Apache NetBeans
A free, open-source IDE from the Apache Software Foundation, with Java SE, Maven, and Gradle support out of the box. Its simple project setup and built-in GUI builder for Swing make it popular in teaching.
Comparison
| IntelliJ IDEA | VS Code + Java | Eclipse | NetBeans | |
|---|---|---|---|---|
| Cost | Free edition plus paid tiers | Free | Free | Free |
| Resource usage | High | Low to moderate | Moderate | Moderate |
| Refactoring depth | Very strong | Good | Strong | Good |
| Setup effort | Low | Install extension pack | Low | Low |
| Best for | Professional Java and Kotlin work | Polyglot developers, lighter projects | Plugin-heavy and legacy enterprise setups | Teaching, Swing GUIs |
All four compile and run every example in this tutorial. For a beginner with no prior preference, IntelliJ IDEA's free edition or VS Code with the Extension Pack for Java are the most common starting points.
Creating and Running a First Project
IntelliJ IDEA
- New Project → choose Java.
- Select a JDK (or let IntelliJ download one).
- Build system: IntelliJ for a simple project, or Maven/Gradle for one that uses a build tool.
- Optionally check Add sample code, then click Create.
- In
src, right-click → New → Java Class → name itMain. - Inside the class type
psvmand press Tab to generatepublic static void main(String[] args). Inside it typesoutand press Tab to generateSystem.out.println();. - Click the green Run arrow next to the
mainmethod.
VS Code
- Install the JDK, then install the Extension Pack for Java from the Extensions view.
- Open the Command Palette (
Ctrl+Shift+P/Cmd+Shift+P) → Java: Create Java Project → No build tools (or Maven/Gradle). - Open
src/App.javaand click Run abovemain.
For a single file, simply open any .java file containing a main method; the Run link appears without creating a project.
Eclipse
- File → New → Java Project, enter a name, select a JRE (JDK), and click Finish.
- Right-click
src→ New → Class, enter a name, and check public static void main(String[] args). - Type
sysoutand pressCtrl+Spaceto expand it toSystem.out.println();. - Run → Run As → Java Application.
Using the Debugger
The debugger lets you pause a running program and inspect its state, which is far more informative than adding println statements.
public class Totals {
public static void main(String[] args) {
int[] prices = {120, 80, 45};
int total = 0;
for (int i = 0; i <= prices.length; i++) { // bug: <= instead of <
total += prices[i];
}
System.out.println(total);
}
}
This program throws ArrayIndexOutOfBoundsException. To investigate:
- Click in the gutter (left margin) next to the line
total += prices[i];to set a breakpoint. - Start the program in Debug mode (the bug icon) rather than Run.
- Execution pauses at the breakpoint. The Variables panel shows
prices,total, andi. - Use Step Over to run one line at a time. Watch
iincrease: 0, 1, 2, then 3, at which pointprices[3]fails.
The cause, i <= prices.length, becomes obvious when you see i reach 3 for a three-element array.
| Debugger action | Effect |
|---|---|
| Step Over | Run the current line, including any method it calls, and stop at the next line |
| Step Into | Enter the method called on the current line |
| Step Out | Finish the current method and stop in its caller |
| Resume | Run until the next breakpoint |
| Conditional breakpoint | Pause only when an expression is true, e.g. i == 2 |
| Evaluate expression | Compute any expression using the current variable values |
Useful Shortcuts and Generators
Every IDE can generate common boilerplate. Given a class with fields:
public class Book {
private String title;
private String author;
private int year;
}
Use Generate (IntelliJ: Alt+Insert on Windows/Linux, Cmd+N on macOS; Eclipse: Source menu) to create a constructor, getters and setters, equals/hashCode, and toString. These methods are easy to write incorrectly by hand, especially equals and hashCode, and the IDE writes them consistently. For a pure data holder, a record (covered in the OOP section) removes the need for most of this generated code entirely.
Other actions worth learning early:
- Quick fix (IntelliJ
Alt+Enter, EclipseCtrl+1, VS CodeCtrl+.): offers a fix for the error or warning under the cursor, such as adding an import or creating a missing method. - Reformat code: applies consistent indentation and spacing to the file.
- Rename (IntelliJ
Shift+F6, EclipseAlt+Shift+R, VS CodeF2): safe, project-wide renaming. - Find usages: lists every reference to the selected class, method, or field.
IDE and Command Line Together
An IDE compiles and runs code using the same JDK tools you use from a terminal. Knowing both matters: build servers, Docker images, and production systems run Java from the command line, with no IDE involved. The following lessons cover the JDK, JRE, JVM, compiler, and the javac and java commands, so that what the IDE does behind its Run button is understood rather than hidden.
When a project uses Maven or Gradle, open the project's pom.xml or build.gradle file in the IDE rather than creating a new IDE project. The IDE then reads dependencies and settings from the build file, so the project builds the same way inside and outside the IDE.