• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF Servlets&JSP compilation prob

 
J Chandler
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone

Reached page 85 without too many hitches but I'm having a tough time re-compiling the BeerSelect servlet class.

Compiler does not recognize package com.example.model (says it doesn't exist.

I feel it may be a classpath problem as I've checked the hierarchy of all the files many times and each package statement therein (hmmmmm).

BTW, I notice that the command line screen dump (p85) has an additional bit after servlet-api.jar
:classes:.

that wasn't used for the first example (p31, step 5).
This does not work for me as it it hides all servlet related code from my compiler and it gets upset and shouts - (I use Windows)

Any advice would be appreciated

Cheers, J
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy -- in the first example (pg 31) we didn't need "classes" on the classpath because the class we compiled didn't need anything that was *in* the classes directory.

But on page 85, we do.

One thing I would check is which directory you are actually in when you run the command-line script. We're assuming that you're in the project (not deployment) directory "beerVI", and the compiler will need to find the com.example.model package which is inside the "classes" directory immediately underneath the "beerV1" project directory.

So I'd recheck that you've done a "cd" into the beerV1 directory of your project/development environment when you run the compile script on page 85.

Usually when you're having a classpath problem with these examples, it's because you're in the deployment directory structure instead of the development directory structure. It's all really confusing... but we wanted you to do it completely by hand rather than using Ant (which would eliminate all these problems!), for the sake of knowing exactly what and where everything is.

Let me know if this isn't the issue and we'll figure it out one way or another. From what we know, the tutorial instructions seem to be correct, though, so you should be able to get it working.

Hang in there! This can be a big pain, I know.

cheers,
Kathy
 
pallavi utukuri
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey
i too had the same error....this worked for me

Compiling BeerSelect.java
Cd myprojects
Cd beer1

javac -classpath /tomcat4.1/common/lib/servlet-api.jar:classes:.; C:\j2sdk1.4.2_05\lib\j2ee.jar; -d classes src/com/example/web/BeerSelect.java

Compiling BeerExpert.java
Cd my projects
Cd beer1

javac -classpath /tomcat4.1/common/lib/servlet-api.jar:classes:.; C:\j2sdk1.4.2_05\lib\j2ee.jar; d:\MyProjects\beerV1\classes -d classes src/com/example/web/BeerSelect.java
--------------------
like kathy said hang in there.....dont giveup!
 
J Chandler
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response

First, Pallavi, I don't have a J2ee.jar file so I think that would not work for me at this point - but thanks anyway mate!

Kathy, I have checked that I'm compiling from the development environment -

I have to type:
cd C:\MyProjects\beerV1


I back-tracked to page 81 and commented out some code from BeerSelect.java so that I had the first version again.

To compile I type:
javac -classpath C:/tomcat/common/lib/servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java


This generates 6 'can't see any servlet related api' type errors.
But, if I compile without :classes:., it works fine.
(I'm guessing that I really NEED to make it compile with :classes:. for the reasons you explained in your post)

Moving on, my BeerExpert.java file DOES compile correctly with :classes:.

This brings me back to version 2 of (naughty)BeerSelect.java, which once again throws up the same 6 'can't see any servlet related api' type errors - PLUS another 3 'ha ha, can't see com.example.model either, so ner' type errors.

All package statements and import statements are present and correct.
I'm stumped

Regards, J
[ September 22, 2004: Message edited by: J Chandler ]
 
J Chandler
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, I've been wandering about trying to find a solution to my problem and for anyone who is having the same trouble...

check out the post from September 14th (command line arguments)

I would like to thank Jaques CestJaques for hitting the nail on the head.

If you are using Windows XP, you need to substitute the colons with semi-colons.

javac -classpath C:/tomcat/common/lib/servlet-api.jar;classes;. -d classes src/com/example/web/BeerSelect.java


Happy days
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic