DEV Community

Md Jamilur Rahman
Md Jamilur Rahman

Posted on

Setting Up Eclipse for Java: A Beginner-Friendly Walkthrough

Eclipse is the old reliable of Java IDEs. It has been around since 2001, and while IntelliJ has eaten a lot of its market share, Eclipse still runs in banks, government offices, and university labs across Bangladesh and the world. If you walk into a job at a large enterprise today, there is a decent chance someone hands you an Eclipse workspace.

This guide covers installing Eclipse, setting up a JDK, creating a project, and writing your first Java class. By the end you will have a working environment and know the shortcuts that make Eclipse productive.

Download and install

Go to the Eclipse downloads page and grab the installer for your operating system. Windows, macOS, and Linux are all supported.

Run the installer and you will see a list of package options. Pick Eclipse IDE for Java Developers. That is the one with the Java tooling, Maven support, and Git integration baked in. The other packages are for C++, PHP, and other languages. You do not need those right now.

The installer handles the rest. On macOS, drag Eclipse to your Applications folder. On Windows and Linux, the installer sets up everything for you. Once it finishes, launch Eclipse.

The JDK situation

Eclipse needs a JDK to compile and run Java code, but it does not download one for you the way IntelliJ does. You need to have a JDK installed before or during setup.

If you do not have one yet, install OpenJDK from Adoptium. Java 21 is a long-term support release and a safe choice for new projects. Java 25 is the newest if you want cutting-edge features. I covered the full JDK installation process in an earlier article.

When you first launch Eclipse, it asks you to choose a workspace. A workspace is just a folder where your projects live. Pick something simple like /home/yourname/workspace or C:\Users\YourName\workspace. You can change this later.

If Eclipse does not find your JDK automatically, go to Window > Preferences > Java > Installed JREs (on macOS, it is Eclipse > Settings). Click Add Standard VM, point it to your JDK installation folder, and check the box next to it. Eclipse remembers this for all future projects.

Create your first project

Go to File > New > Java Project. In the dialog:

  1. Give your project a name. Call it eclipse-demo.
  2. Under JRE, make sure your JDK is selected. If you set it up in the Installed JREs screen, it shows up here.
  3. Leave the module options alone for now. You do not need modules for a learning project.
  4. Eclipse may ask if you want to create a module-info.java file. Click Don't Create. Modules are an advanced topic you can learn later.

Click Finish. Your project shows up in the Package Explorer on the left side.

Understand the layout

Here is what your project structure looks like:

eclipse-demo/
├── src/                ← your code goes here
├── bin/                ← compiled .class files (auto-generated)
└── .settings/          ← Eclipse config (don't touch)
Enter fullscreen mode Exit fullscreen mode

The src folder is where your .java files live. The bin folder is where Eclipse puts the compiled bytecode. You never edit files in bin directly. Eclipse recompiles automatically every time you save.

Write and run your first class

Right-click the src folder and select New > Class. In the dialog:

  1. Name it Main.
  2. Check the box that says public static void main(String[] args). This saves you typing the method signature by hand.
  3. Click Finish.

Eclipse creates the class and the main method for you. Replace the body with a print statement:

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello from Eclipse!");
    }
}
Enter fullscreen mode Exit fullscreen mode

Save the file. Now click the green play button in the toolbar, or press Ctrl+F11 (Cmd+F11 on Mac). Your output shows up in the Console tab at the bottom.

Here is a slightly more useful example. Say you are building a simple grocery bill calculator for a shop in Dhaka:

public class Main {
    public static void main(String[] args) {
        double rice = 65.0;    // per kg
        double dal = 120.0;    // per kg
        double oil = 180.0;    // per litre

        double total = rice + dal + oil;
        System.out.println("Total bill: Tk " + total);
    }
}
Enter fullscreen mode Exit fullscreen mode

Run it and the Console prints Total bill: Tk 365.0. You just wrote and ran real Java without touching a command line.

Code completion

As you type, Eclipse suggests class names, methods, and variables. Press Ctrl+Space and a popup appears with options. Type Sys then Ctrl+Space and Eclipse offers System. Type .out.print then Ctrl+Space and it completes the method call. This saves you from typos and from memorizing the standard library.

If you type something that needs an import (like Scanner), Eclipse underlines it in red. Click the red marker or press Ctrl+1 and Eclipse offers to add the import statement for you. Think of Ctrl+1 as the quick-fix key. Missing semicolon? Ctrl+1 fixes it. Undefined variable? Ctrl+1 offers to declare one.

Debugging

Running with the debugger lets you pause your code and inspect it line by line. Double-click in the left margin next to a line number to set a breakpoint. A blue dot appears. Now click the bug icon in the toolbar, or press F11.

When execution hits your breakpoint, it stops. From there:

  • F6 steps to the next line without going inside methods
  • F5 steps into a method to inspect what happens inside
  • F8 resumes execution until the next breakpoint

While paused, look at the Variables tab. It shows every variable and its current value. If total looks wrong, you can trace backward through your steps to find where the calculation went off. This is how you actually find bugs instead of guessing.

Organize imports and formatting

Press Ctrl+Shift+O to organize imports. It removes unused ones and adds any that are missing. Press Ctrl+Shift+F to reformat your code to standard Java style. Run these two before you commit anything and your code will always look tidy.

Eclipse vs other IDEs

Is Eclipse the right choice for you? It is free, open source, and handles large enterprise projects well. If you are applying for jobs at banks or government tech divisions in Bangladesh, knowing Eclipse is an advantage because that is what those shops run.

IntelliJ has better code intelligence out of the box, and VS Code is lighter and faster. I covered both in previous articles. The good news is that Java concepts transfer between IDEs. Once you understand projects, packages, and classpaths in Eclipse, you understand them everywhere.

Quick summary

  • Download Eclipse IDE for Java Developers from eclipse.org.
  • A workspace is just a folder. Pick one and move on.
  • Code goes in src. Compiled output goes in bin automatically.
  • Ctrl+Space for code completion. Ctrl+1 for quick fixes. Ctrl+F11 to run.
  • Debug with breakpoints (F6 to step over, F5 to step in, F8 to resume).
  • Ctrl+Shift+O organizes imports. Ctrl+Shift+F formats your code.

Based on dev.java/learn: Setting up Eclipse and the Eclipse documentation.

Top comments (0)