I am facing the same problem.
I already set my classpath like this ".;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar;F:\MyProjects\beerV1\src\com\example\model\BeerExpert.class"
In F:\MyProjects\beerV1\src\com\example\model folder i have BeerExpert.java which is successfully compiled.
package com.example.*;
import java.util.*;
@SuppressWarnings("unchecked")
public class BeerExpert {
public List getBrands(
String color){
List brands = new ArrayList();
if (color.equals("amber")) {
brands.add("Jack Amber");
brands.add("Red Moose");
}
else {
brands.add("Jail Pale Ale");
brands.add("Gout Stout");
}
return(brands);
}
}
And Now in F:\MyProjects\beerV1\src\com\example\web I have my BeerSelect.java
package com.example.web;
import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class BeerSelect extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Beer Selection Advice
");
String c = request.getParameter("color");
BeerExpert be = new BeerExpert();
List result = be.getBrands(c);
Iterator it = result.iterator();
while(it.hasNext()) {
out.println("
try: " + it.next());
}
}
}
and when ever i try to compile it i have following error:
F:\MyProjects\beerV1\src\com\example\web>javac BeerSelect.java
BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
BeerSelect.java:16: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
BeerSelect.java:16: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
3 errors
F:\MyProjects\beerV1\src\com\example\web>