• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

compilation error

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,
I have a problem, for your info. it from chapter 3 of Head first Servlets and Jsp. I have this Servlet code below and the Model code also below.I have imported the model package in line 2 of servlet code, but when I compile it in Windows XP it says model package does not exit and gives the error message as shown below.Please help.I am a beginner.
Monica


Servlet Code:

package com.example.web;
import com.example.model.*; --- Here I am importing the Package of Model
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

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 Selectio Advice<br>");
String c= request.getParameter("color");


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


Error Message:


C:\Documents and Settings\Monica\Desktop\MyProjects\beerV1\src\com\exampl
e\web>javac BeerSelect.java
BeerSelect.java:2: package com.example.model does not exist
import com.example.model.*;
^
BeerSelect.java:17: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
BeerSelect.java:17: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
BeerSelect.java:19: cannot find symbol
symbol : method Iterator()
location: interface java.util.List
Iterator it = result.Iterator();
^
4 errors

C:\Documents and Settings\Monica\Desktop\MyProjects\beerV1\src\com\exampl
e\web>
[ February 04, 2006: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not a servlets question. Moved to Java in General (beginner) with an appropriate change of title.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try compiling with a classpath so that the package can be found. For example, if the location is c:\myJava\com\example\model, then try compiling with...

javac -classpath c:\myJava BeerSelect.java
 
We don't have time for this. We've gotta save the moon! Or check this out:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic