• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

package com.example.model does not exist

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am on page 82 of Head First and am compiling BeerExpert.

i created beerexpert.java as following:

------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------

i compiled this above java file successfully.
then i created beerselect.java as following:

-----------------------------------------------------------------------------------------------------------------


--------------------------------------------------------------------------------------------------------------------

then i used followig commands to compile it:



E:\MyProjects\beerV1\src\com\example\web> //reached dir where beerselect.java exists.

E:\MyProjects\beerV1\src\com\example\web>javac beerselect.java


beerselect.java:4: package com.example.model does not exist
import com.example.model.*;
^
beerselect.java:20: cannot find symbol
symbol : class beerexpert
location: class com.example.web.beerselect
beerexpert b=new beerexpert();
^
beerselect.java:20: cannot find symbol
symbol : class beerexpert
location: class com.example.web.beerselect
beerexpert b=new beerexpert();
^
3 errors

------------------------------------------------------------------------------------------------------------------------
I have already set environment variables as following:

CLASSPATH C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar
JAVA_HOME C:\Program Files\Java\jdk1.6.0
PATH C:\Program Files\Java\jdk1.6.0\bin

development environment dir structure is same as depicted in the book.

one more thing i am not willing to write long classpath in my compiling command. So, is there any way?
what should i do to remove these errors?
please help me out.
thanks in advance
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

beerexpert b=new beerexpert();



Java is case sensitive. Try

BeerExpert b=new BeerExpert();



Also please use code tags when you post code.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"wickedostrich inKnit"

Please check your private messages regarding an important administrative matter.

-Andrew
 
veebhu singh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tom Reilly wrote:

beerexpert b=new beerexpert();



Java is case sensitive. Try

BeerExpert b=new BeerExpert();



Also please use code tags when you post code.





nah, actually i mistook in post about case sensitiveness.
In my code, everything is proper regarding case sensitive characteristic of java.
The problem lies somewhere else.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two things: First, please read PostRealCode. Then, please check your private messages.

 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can JVM find a class which is not in your class path. Try below mentioned which put your first class in class path


C:\MyFolder\MySoftwareLab\tools\quicktest\com\example\web>javac -cp C:\MyFolder\
MySoftwareLab\tools\quicktest beerselect.java
 
veebhu singh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

shivendra tripathi wrote:How can JVM find a class which is not in your class path. Try below mentioned which put your first class in class path


C:\MyFolder\MySoftwareLab\tools\quicktest\com\example\web>javac -cp C:\MyFolder\
MySoftwareLab\tools\quicktest beerselect.java



would you please explain a bit more because I am not able to manipulate it in my directory structure.
I would like to add that my directory structure is as following:

E:\MyProjects\beerV1\src\com\example\model\beerexpert.java


E:\MyProjects\beerV1\src\com\example\web\beerselect.java


and as depicted in original post, I have already set environment variables as following:

CLASSPATH C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar
JAVA_HOME C:\Program Files\Java\jdk1.6.0
PATH C:\Program Files\Java\jdk1.6.0\bin

If you tell me the exact command which I should use, I'll be highly thankful.
-Regards.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compile from the "src" directory and include the current directory in the javac command's classpath.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just include the following in your enviornment variables as classpath and you are good to go :

E:\MyProjects\beerV1\src
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic