This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Problem in compiling this code

 
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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Merry Christmas
 
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!