Forums Register Login
ignore last post - incomplete - this one good
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

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


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


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 ]
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.
    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.

    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.

    Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

    This thread has been viewed 572 times.

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 20, 2018 23:35:51.