This week's giveaway is in the Java in General forum.
We're giving away four copies of Java Challengers and have Rafael del Nero on-line!
See this thread for details.
Win a copy of Java Challengers this week in the Java in General forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Problem in compiling this code

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merry Christmas
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic