Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes File not getting imported Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "File not getting imported" Watch "File not getting imported" New topic

File not getting imported

Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
I am trying to run the first application in MVC in HFSJ.
Some how it's not recognizing the first import statement .
I am getting the error "package com.example.model does not exist"

Here's the code :

BeerSelect Java file

BeerExpert File

The directory structure is

beerV1 --> classes --> com --> example -->web -->
beerV1 --> classes --> com --> example -->model --> BeerExpert.class

beerV1 --> src --> com --> example -->web -->
beerV1 --> src --> com --> example -->model -->

The command line
" javac -classpath "C:/program files (x86)/Apache Software Foundation/Tomcat 5.5/servlet-api.jar" -d classes src/com/example/web/"
I am executing it from the beerV1 folder.

I know it's something small and silly . Just can't pin it

The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Roel De Nijs

Joined: Jul 19, 2004
Posts: 5139

When you try to compile your classpath must contain 2 entries: one for the servlet api and one for the already compiled BeerExpert class. Your classpath just contains an entry fpr the servlet api, so that's why it is not compiling.

javac -cp classes;"C:/program files (x86)/Apache Software Foundation/Tomcat 5.5/servlet-api.jar" -d classes src/com/example/web/ should do the trick

SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Thanks alot ! That did the job
jQuery in Action, 2nd edition
subject: File not getting imported
Similar Threads
package does not exist problem
Compiling problems
problen in headfirst mvc tutorial
weird problem
can't import own model