Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package com.example.model does not exist

 
veebhu singh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • 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.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11856
187
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two things: First, please read PostRealCode. Then, please check your private messages.

 
shivendra tripathi
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compile from the "src" directory and include the current directory in the javac command's classpath.
 
Nishant Sharmaster
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic