Eclipse on Ubuntu for J2ee

"Install or update Eclipse to have Eclipse Web Tools Platform (WTP)."

Eclipse can be configured on Ubuntu (8.4) as follows :

1. Stop all apache and tomcat servers or any other if running on your host
/etc/init.d/apache2 stop
/etc/init.d/tomcatX.X stop

P.S : You need to be the root or use sudo .

2.Create a new dynamic web project
Click on New>Projects>Dynamic web project.
Enter the name click finish.

3.Add a new server on your localhost
Click on the server tab
Right click and new server
Select Basic>>J2EE Preview at localhost (or any other appropriate for your need )

4.Test your server by starting it
Right click start
If any conflicts in the port , change the port of your local server

5.Create a Servlet in your project directory
Try this ever famous "Hello World!!" { Add HTML Tags if required }

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("Hello World!");

}
}

6.Right click on your server and select add or remove projects and add your current project

7.Run as >>Run on Server

P.S If u find any errors as can not import javax.servlet.*; go to project properties >>Java build>>Add external jar
and add Servlet.jar i downloaded it from here

8.Learn Run and be Happy :) Share this