Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in compiling this code

 
sudhakar karnati
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry for the previous post(Image did not get uploaded)..I tried to delete that post but i could not do that...

Here i am again posting freshly..

I started reading HFSJ but i stuck at the page number 84.In this page there is a code for servlet version two and the code is like this

code:


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 req,HttpServletResponse res)throws IOException,ServletException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("Beer Selection Advice<br>");
String c= req.getParameter("color");

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



My folder structure is likie
D:\SCWCD Practice\MyProjects\beerv1

In Beerv1 folder structure is like
classes\com\example\web\BeerSelect.class (This is the Action servlet)

and

classes\com\example\model\BeerExpert.class (This is the Model class)

and the java files are in the following directories
beerv1\src\com\example\model\BeerExpert.java (Java file for Model class)

and

beerv1\src\com\example\web\BeerSelect.java (Java file for Action servlet)


I am following the same path as it is mentioned in the HFSJ book page no 72 1nd 73

The problem i am facing is


D:\SCWCD Practice\MyProjects\beerv1\classes>javac -d classes BeerSelect.java
BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
BeerSelect.java:18: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
BeerSelect.java:18: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
3 errors


I think there is a problem with the package structure Please solve my problem..

The Action servlet is under one directory structure and Model class what i am trying to import is in another diretory structure.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I removed it. Maybe you could not remove it because I already replied there.

Looks like basic (Java In General (Beginner)) compilation problem, doesn't it ? If the "src" directory was in the CLASSPATH, there should not be any problem. If you don't know how to set the classpath, please read this FAQ.
 
sudhakar karnati
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Christophe Verre

The problem is solved..And i think now you can close this topic..

Merry Christmas..
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Merry Christmas
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic