File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes package com.example.model does not exist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "package com.example.model does not exist" Watch "package com.example.model does not exist" New topic
Author

package com.example.model does not exist

veebhu singh
Greenhorn

Joined: Jun 19, 2010
Posts: 11

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

Joined: Jun 01, 2010
Posts: 618
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

Joined: Mar 28, 2003
Posts: 11525
    
100

"wickedostrich inKnit"

Please check your private messages regarding an important administrative matter.

-Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
veebhu singh
Greenhorn

Joined: Jun 19, 2010
Posts: 11
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

Joined: Jan 10, 2002
Posts: 61764
    
  67

Two things: First, please read PostRealCode. Then, please check your private messages.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
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


SCJP 1.5(97%) My Blog
veebhu singh
Greenhorn

Joined: Jun 19, 2010
Posts: 11
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

Joined: Sep 29, 2008
Posts: 12617

Compile from the "src" directory and include the current directory in the javac command's classpath.
Nishant Sharmaster
Greenhorn

Joined: Mar 20, 2013
Posts: 1
Just include the following in your enviornment variables as classpath and you are good to go :

E:\MyProjects\beerV1\src
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: package com.example.model does not exist