Reputation: 4249
I am newbie to j2ee. I have download and installed j2eesdk-1_4_03-linux.bin in my ubuntu 10.04 distribution. and then i tried to code my first servlet in it as:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HowdyServlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println("<html>");
out.println("<head><title>howdy</title></head>");
out.println("<body>");
out.println("<center><h1>Howdy</h1></center>");
out.println("</body>");
out.println("</html>");
}
}
and here are the environment variables i set after installation:
1. J2EE_HOME=/home/vinit/SUNWappserver
2. JAVA_HOME=/home/vinit/SUNWappserver/jdk
3. CLASSPATH=/home/vinit/SUNWappserver/lib
and now i tried to compile the servlet using
javac HowdyServelet.java
But i got following errors:
HowdyServlet.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
HowdyServlet.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
HowdyServlet.java:5: cannot find symbol
symbol: class HttpServlet
public class HowdyServlet extends HttpServlet{
^
HowdyServlet.java:6: cannot find symbol
symbol : class HttpServletRequest
location: class HowdyServlet
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
^
HowdyServlet.java:6: cannot find symbol
symbol : class HttpServletResponse
location: class HowdyServlet
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
^
HowdyServlet.java:6: cannot find symbol
symbol : class ServletException
location: class HowdyServlet
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
^
6 errors
So how to compile this servlet. Thanks in advance.
Upvotes: 1
Views: 1391
Reputation: 328556
Setting CLASSPATH=/home/vinit/SUNWappserver/lib
has no desired effect; you have to name each JAR you want on the classpath individually.
Upvotes: 2
Reputation: 52635
You are not going to be able to compile it until you change servelet
to servlet
Upvotes: 0