Problem compiling a simple java file
Hi,
When I try to compile the following simple java file
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("<body>");
out.println("<center><h1>Hi</h1></center>");
out.println("</body>");
out.println("</html>");
}
}
at the command prompt as follows
C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac -classpath
"C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip" *.java
Or
C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac *.java
Or
C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac HowdyServlet.java
I get the following errors and I cannot compile this java file -
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,
^
HowdyServlet.java:7: cannot find symbol
symbol : class HttpServletResponse
location: class HowdyServlet
HttpServletResponse response)
^
HowdyServlet.java:8: cannot find symbol
symbol : class ServletException
location: class HowdyServlet
throws IOException, ServletException {
^
6 errors
I have installed the latest JEE 5 SDK on Win XP Home. I have the following variable set as follows,
CLASSPATH = .;C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip
PATH = C:\Sun\AppServer\jdk\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\QuickTime\QTSystem;C:\Sun\AppServer\lib\ant\bin
ANT_HOME = C:\Sun\AppServer\lib\ant
I have spent hours scratching my head but don抰 have a clue. I was wondering if you have any idea as why I might be getting these errors.
Thank you for your time.
Green

