File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes servlet compiling errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "servlet compiling errors" Watch "servlet compiling errors" New topic

servlet compiling errors

chailin fong

Joined: Oct 15, 2007
Posts: 10
I am following an exercise from HFJS and encounter compile errors.

I have two servlet files named and

I create a development like this:
--------------------------model (
--------------------------web (


1) I compiled from command prompt:

c:\myprojects\beerv1> javac -classpath "c:\program files\tomcat 5.0\common\lib\servlet-api.jar:classes: ." -d classes src\com\example\model\

it created BeerExpert.class successfully in c:\myprojects\beerV1\classes\com\example\model

2) When compiled

c:\myprojects\beerv1> javac -classpath "c:\program files\tomcat 5.0\common\lib\servlet-api.jar:classes: ." -d classes src\com\example\web\

I got 11 errors.

The error message indicates, such as:
src\com\example\web\ package com.example.model does not exist"
import com.example.model.*;
src\com\example\web\ package javax.servlet does not exist"
and so on...




package com.example.web;

import com.example.model.*;

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");

/* instantiate the BeerExpert class and call getBrands() */

BeerExpert be = new BeerExpert();
List result = be.getBrands(c);
Iterator it = result.Iterator();
while (it.hasNext()){
out.print("<br>try: " +;




package com.example.model;

import java.util.*;

public class BeerExpert{

public List getBrands(String color){

List brands = new ArrayList();
if (color.equals("amber")){

brands.add("Jack Amber");
brands.add("Red Moose");


brands.add("Jail Pale Ale");
brands.add("Gout Stout");


Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
On Windows, the character that separates classpath entries is not ":", but ";". So the classpath should read

Also make sure it doesn't contain any extra spaces, like the one that you had after "classes:".
I agree. Here's the link:
subject: servlet compiling errors
It's not a secret anymore!