File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problem in compiling this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Problem in compiling this code" Watch "Problem in compiling this code" New topic
Author

Problem in compiling this code

sudhakar karnati
Ranch Hand

Joined: May 03, 2007
Posts: 93
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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.


[My Blog]
All roads lead to JavaRanch
sudhakar karnati
Ranch Hand

Joined: May 03, 2007
Posts: 93
Thanks Christophe Verre

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

Merry Christmas..
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Merry Christmas
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Problem in compiling this code