• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

ignore last post - incomplete - this one good

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Need someone's help.

I am trying to compile BeerSelect.java on Head First page 84. I am receiving the message "package com.example.model does not exist".

BeerExpert.java is in C:\MyProjects\beerV1\src\com\example\model

BeerExpert.class is in C:\MyProjects\beerV1\classes\com\example\model
and in C:\Tomcat\webapps\BeerV1\WEB-INF\classes\com\example\model

BeerSelect.java is in C:\MyProjects\beerV1\src\com\example\web

CLASSPATH .;C:\MyProjects\beerV1\classes;C:\Tomcat\common\lib\servlet-api.jar;C:\Tomcat\common\lib\jsp-api.jar

JAVA_HOME
C:\Program Files\Java\jdk1.5.0_01

PATH

... then at the end C:\Program Files\Java\jdk1.5.0_01\bin

TOMCAT_HOME C:\Tomcat



BeerSelect.java :



BeerExpert.java:




web.xml:



C:MyProjects\beerV1\src\com\example\web\BeerSelect.java

results in the package com.example.model does not exist message.


Greatly appreciate any help.

Jerry Bustamente

[EDIT code tags added by Dave. See how much easier that is to read?]
[ January 29, 2005: Message edited by: David O'Meara ]
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jerry, to help us help you:
  • you can edit posts to fix errors rather than reposting twice
  • use the 'code' tag for code sections. it makes it mush easier to read.

  • We appreciate your cooperation.
     
    David O'Meara
    Rancher
    Posts: 13459
    Android Eclipse IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Have you tried removing com.example.model.* from your import list?
    As a matter of style, it's good form to explicitly include every import by name rather than using .*

    It's much easier to manage with the intelligent IDEs now.

    Dave
     
    David O'Meara
    Rancher
    Posts: 13459
    Android Eclipse IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    OK, I see the problem now. My mistake.

    When you compile class A, it needs to be able to see class B on the classpath. If you compile BeerSelect.java from the C:\MyProjects\beerV1\src\com\example\web directory, that file will begin to compile OK, but when it looks for com.example.model.BeerExpert, this class cannot be found on the classpath.

    You have two simple options: add C:\MyProjects\beerV1\src to the classpath so that both packages are always available, or compile from the C:\MyProjects\beerV1\src directory as javac com\example\web\BeerSelect.java

    In the second example, the required directory is the '.' directory on your classpath, so this way you don't need to add it explicitly.

    Dave
     
    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