Eclipse Java Web IDE Setup on Ubuntu

Yes. Here is a step-by-step Eclipse Java Web IDE setup on Ubuntu, suitable for Java + Maven + Servlets/JSP + Tomcat development.

1. Check Java

Open Terminal:

java -version
javac -version

If Java is not installed:

sudo apt update
sudo apt install openjdk-21-jdk -y

Verify:

java -version

Find Java location:

readlink -f $(which java)

Typically:

/usr/lib/jvm/java-21-openjdk-amd64/bin/java

2. Install Eclipse IDE for Enterprise Java and Web Developers

For Java web development, install the Eclipse IDE for Enterprise Java and Web Developers, rather than the basic Java package.

Image

Download Eclipse from the official site:

Eclipse Downloads

You can also install the Eclipse installer from the terminal after downloading it.

For example, if the downloaded file is:

eclipse-inst-jre-linux64.tar.gz

Extract it:

tar -xzf eclipse-inst-jre-linux64.tar.gz

Enter the directory:

cd eclipse-installer

Run:

./eclipse-inst

Select:

Eclipse IDE for Enterprise Java and Web Developers

Then choose your installation directory, for example:

/home/$USER/eclipse

Click Install.


3. Start Eclipse

After installation:

~/eclipse/jee-*/eclipse

Alternatively, start Eclipse from the Ubuntu application menu.

When Eclipse asks for a workspace, use something like:

/home/$USER/eclipse-workspace

4. Configure Java in Eclipse

Go to:

Window
 → Preferences
   → Java
     → Installed JREs

Click Add…

Choose:

Standard VM

Set the JRE location to:

/usr/lib/jvm/java-21-openjdk-amd64

Select the newly added JDK.

You should see something similar to:

☑ java-21-openjdk-amd64

Click:

Apply and Close

5. Install Apache Tomcat

For Java web applications, you’ll need a servlet container such as Apache Tomcat.

Download Tomcat from the official site:

Apache Tomcat

For example, download a Tomcat 10.x tarball.

Then:

cd ~/Downloads
tar -xzf apache-tomcat-10*.tar.gz

Move it somewhere convenient:

sudo mv apache-tomcat-10* /opt/tomcat

Give yourself ownership:

sudo chown -R $USER:$USER /opt/tomcat

Start Tomcat:

/opt/tomcat/bin/startup.sh

You should see something similar to:

Tomcat started.

Open:

http://localhost:8080

If the Tomcat page appears, Tomcat is working.

Stop it with:

/opt/tomcat/bin/shutdown.sh

6. Add Tomcat to Eclipse

Open Eclipse.

Go to:

Window
 → Preferences
 → Server
 → Runtime Environments

Click:

Add...

Select your Tomcat version, for example:

Apache → Tomcat v10.1 Server

Click Next.

For Tomcat installation directory, select:

/opt/tomcat

For the JRE, select:

Java 21

Click:

Finish
 → Apply and Close

7. Create a Dynamic Web Project

In Eclipse:

File
 → New
 → Dynamic Web Project

If you don’t see it, use:

File
 → New
 → Other

Then search:

Dynamic Web Project

Create:

Project name: HelloWeb

For Target Runtime select:

Apache Tomcat

For Dynamic Web Module, choose the version appropriate for your Tomcat.

Click:

Finish

You should get a structure similar to:

HelloWeb
├── Java Resources
│   └── src
├── WebContent
│   ├── META-INF
│   └── WEB-INF
└── ...

Depending on Eclipse/Tomcat/Jakarta configuration, newer projects may instead use a Maven-style structure.


8. Create a simple HTML page

Create:

index.html

Example:

<!DOCTYPE html>
<html>
<head>
    <title>Hello Web</title>
</head>
<body>

<h1>Hello from Eclipse!</h1>

<p>My first Java web application.</p>

</body>
</html>

9. Create a Servlet

Right-click your Java source folder:

New
 → Servlet

Use:

Class name: HelloServlet

For a Jakarta-based Tomcat application, the servlet will look like:

package com.example;

import java.io.IOException;
import java.io.PrintWriter;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

@WebServlet("/hello")
public class HelloServlet extends HttpServlet {

    @Override
    protected void doGet(
            HttpServletRequest request,
            HttpServletResponse response)
            throws ServletException, IOException {

        response.setContentType("text/html");

        PrintWriter out = response.getWriter();

        out.println("<html>");
        out.println("<body>");
        out.println("<h1>Hello from Java Servlet!</h1>");
        out.println("</body>");
        out.println("</html>");
    }
}

10. Run the Web Application

Right-click the project:

Run As
 → Run on Server

Select:

Tomcat

Click Finish.

Eclipse will start Tomcat and deploy your application.

Open:

http://localhost:8080/HelloWeb/

For the servlet:

http://localhost:8080/HelloWeb/hello

You should see:

Hello from Java Servlet!

11. Recommended setup for Maven

Since you’ve also been setting up Java and Maven, I recommend using Maven for your web applications rather than manually managing .jar files.

A typical Maven web project is:

HelloWeb/
├── pom.xml
└── src/
    ├── main/
    │   ├── java/
    │   │   └── com/example/
    │   │       └── HelloServlet.java
    │   └── webapp/
    │       └── index.html
    └── test/

Your pom.xml can contain the Jakarta Servlet API dependency:

<dependency>
    <groupId>jakarta.servlet</groupId>
    <artifactId>jakarta.servlet-api</artifactId>
    <version>6.0.0</version>
    <scope>provided</scope>
</dependency>

Then build:

mvn clean package

The WAR file will be generated under:

target/

For example:

target/HelloWeb.war

Important

There are two common Java web stacks:

StackTomcatPackage
Older Java EETomcat 9javax.servlet.*
Modern Jakarta EETomcat 10+jakarta.servlet.*

For a new project, I recommend Java 21 + Maven + Tomcat 10.1 + Jakarta Servlet.

A good next step is to build a complete Maven Servlet/JSP project in Eclipse, including pom.xml, web.xml, Servlet, JSP, and Tomcat deployment.

Leave a Reply

Your email address will not be published. Required fields are marked *