This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Classpath problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Classpath problem" Watch "Classpath problem" New topic

Classpath problem


Joined: Jan 10, 2006
Posts: 4
I have the same problem in this post:

I get a "package javax.servlet does not exist" error when I try to use -classpath to specify the servlet-api.jar file in the Tomcat\common\lib directory. And yes...I can get the servlet to compile by adding setting the CLASSPATH environment variable in Windows....but I should still be able to compile this by using the -classpath option, right? Does anyone know what I'm doing wrong? Here is my source:

package com.example.web;

import javax.servlet.*;
import javax.servlet.http.*;

public class BeerSelect extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
PrintWriter out = response.getWriter();
out.println("Beer Selection Advice<br>");
String c = request.getParameter("color");
out.println("<br>Got beer color " + c);

Here is the path to servlet-api.jar:

Here is what I'm entering with the first couple of errors that get generated:

C:\Data\Java\WebProjects\beerV1>javac -classpath C:\Tomcat\common\lib\servlet-api.jar:classes:. -d classes src\com\example\web\
src\com\example\web\ package javax.servlet does not exist
import javax.servlet.*;
src\com\example\web\ package javax.servlet.http does not exist

import javax.servlet.http.*;
src\com\example\web\ cannot find symbol
symbol: class HttpServlet
public class BeerSelect extends HttpServlet{

I'm sure it's just something stupid that I can't see. Please help!!!


Joined: Jan 10, 2006
Posts: 4
Nevermind. The problem was using colons in my classpath instead of semicolons.


Thanks anyways.
I agree. Here's the link:
subject: Classpath problem
Similar Threads
compiling problem with HF JSP book
Error in compliing Servlet
can't import own model
classpath help with examples
problem in compiling servlet