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

very new and very lost...

Lee McKenney
Greenhorn

Joined: Oct 16, 2003
Posts: 7
Greetings all,
I'm new to the board and new to Java development. I've installed Apache 2.0.47, Tomcat 4.1.27, the Java JDK 1.4.2_01, and MySQL. Through some miracle I've managed to get Apache to talk to Tomcat.
Here's the rub. When following an example I found on creating tags, I am receiving an error indicating that the following package does not exist: javax.servlet.jsp.*; The line of code is - import javax.servlet.jsp.*;
CLASS_PATH is as follows: .;c:\j2sdk1.4.2_01\lib;c:\j2sdk1.4.2_01\jre\lib\ext\mysql-connector-java-3.0.9-stable-bin.jar
I've looked and looked and cannot find anything that has helped. If I understand correctly, it is looking for *.jar files in javax/servlet/jsp, and if that is true I would expect to find this directory structure on the file system and cannot.
Can some kind soul please take the time to explain to me why I am getting this error and what I can do to correct it?
Regards,
Lee
Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
You must also include on your classpath the location of servlet.jar. This is usually located in the <TOMCAT_DIR>/common/lib directory.
Hope this helps.


Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
Lee McKenney
Greenhorn

Joined: Oct 16, 2003
Posts: 7
Jason,
Thanks for the quick response. I did find the the servlet.jar file in 'C:\ApacheGroup\Tomcat4\commom\lib'. I tried each of the following and neither seemed to help...
CLASSPATH= .;c:\j2sdk1.4.2_01\lib;c:\ApacheGroup\Tomcat4\commom\lib\servlet.jar;c:\j2sdk1.4.2_01\jre\lib\ext\mysql-connector-java-3.0.9-stable-bin.jar
CLASSPATH= .;c:\j2sdk1.4.2_01\lib;c:\ApacheGroup\Tomcat4\commom\lib;c:\j2sdk1.4.2_01\jre\lib\ext\mysql-connector-java-3.0.9-stable-bin.jar
Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
Originally posted by Lee McKenney:

CLASSPATH= .;c:\j2sdk1.4.2_01\lib;c:\ApacheGroup\Tomcat4\commom\lib\servlet.jar;c:\j2sdk1.4.2_01\jre\lib\ext\mysql-connector-java-3.0.9-stable-bin.jar
CLASSPATH= .;c:\j2sdk1.4.2_01\lib;c:\ApacheGroup\Tomcat4\commom\lib;c:\j2sdk1.4.2_01\jre\lib\ext\mysql-connector-java-3.0.9-stable-bin.jar

Are you putting the proper spaces in your entries. If I am not mistaken, the default installation of tomcat goes to
c:\Program Files\Apache Group\Tomcat4\
Notice the spaces between Apache and Group.
Best Regards,
Lee McKenney
Greenhorn

Joined: Oct 16, 2003
Posts: 7
Jason,
The paths you see are correct. I was earlier advised to not accept the default installation directories as Apache and Tomcat may not like the use of spaces in directory names.
Lee
Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
Hmmmmm... I don't know why it would not be working then. Maybe try posting the question here
Which is the Apache/Tomcat forum and see if those gurus can help.
Best Regards,
Lee McKenney
Greenhorn

Joined: Oct 16, 2003
Posts: 7
Jason,
Thanks again for your help. I'll post over in the Apache/Tomcat forum and see if those folks have an idea.
Regards,
Lee
Michael Fitzmaurice
Ranch Hand

Joined: Aug 22, 2001
Posts: 168
Lee
I don't know if this is just a typo in your post, as opposed to your classpath, but you have the word 'commom' instead of 'common' in your path to the jar file:
CLASSPATH= .;c:\j2sdk1.4.2_01\lib;c:\ApacheGroup\Tomcat4\commom\lib\servlet.jar;c:\j2sdk1.4.2_01\jre\lib\ext\mysql-connector-java-3.0.9-stable-bin.jar

Michael


"One good thing about music - when it hits, you feel no pain" <P>Bob Marley
Lee McKenney
Greenhorn

Joined: Oct 16, 2003
Posts: 7
Thanks, I checked and it's typo in the message only.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Originally posted by Lee McKenney:
When following an example I found on creating tags, I am receiving an error indicating that the following package does not exist: javax.servlet.jsp.*; The line of code is - import javax.servlet.jsp.*;
CLASS_PATH is as follows: .;c:\j2sdk1.4.2_01\lib;c:\j2sdk1.4.2_01\jre\lib\ext\mysql-connector-java-3.0.9-stable-bin.jar

Is this a compile time problem or a runtime problem? If it's a compile time problem, how are you compiling? With an IDE? What an IDE?
Can you import classes in other packages that would be in that same servlet.jar? Something like import javax.servlet.http.*?
CLASSPATH is CLASSPATH not CLASS_PATH.
If I understand correctly, it is looking for *.jar files in javax/servlet/jsp, and if that is true I would expect to find this directory structure on the file system and cannot.

Nope. The import statement is saying, look for all classes in the javax.servlet.jsp package, and yes, someplace would be a matching directory structure with some class files in javax/servlet/jsp, but that directory structure with lots of class files could well be zipped up inside a single JAR file. According to the CLASSPATH value above, class files are to be looked for in:
  • . - the current working directory
  • c:\j2sdk1.4.2_01\lib - this folder
  • c:\j2sdk1.4.2_01\jre\lib\ext\mysql-connector-java-3.0.9-stable-bin.jar - and in this JAR file


  • [How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
    Lee McKenney
    Greenhorn

    Joined: Oct 16, 2003
    Posts: 7
    Dirk,
    Thanks loads! Your explanation helped tremendously. During my reading, I never picked up on that fact that "that directory structure with lots of class files could well be zipped up inside a single JAR file". A light was turned on with that one line!
    The error is being returned when I execute javac.exe from a Command Prompt in Windows XP. I did verify that CLASSPATH is CLASSPATH and not CLASS_PATH, as I had typed.
    I'll persue the link to the FAQ's that you provided.
    Regards,
    Lee
    Lee McKenney
    Greenhorn

    Joined: Oct 16, 2003
    Posts: 7
    Well I think with everyone's help I've solved this riddle. javax.servlet.jsp.* resides in apache\tomcat4\common\lib\servlet.jar and since this was not on the CLASSPATH the compiler could not resolve the reference.
    This now begs a few more questions.
    1.) Given the number of jar files, it doesn't seem practical to include all of these in the CLASSPATH does it?
    2.) How does one go about determining what classes are included in what jar files? I'm guessing there should be some documentation for this.
    3.) Knowing the answer to number 2 would also help in determining which imports are needed when writing classes/tags?
    Thanks again, I'm off to hit the docs.
    Regards,
    Lee
    Jason Kretzer
    Ranch Hand

    Joined: May 31, 2001
    Posts: 280
    You could do one of two things to find out what classes are in each jar in the common/lib directory. Here is a link to the J2EE website at Sun.
    J2EE API
    Or you could manually go through each one with jar -tf <name_of_jar>.jar and it will list the contents of the jar.
    Best Regards,
    Thomas Paul
    mister krabs
    Ranch Hand

    Joined: May 05, 2000
    Posts: 13974
    One way to gain access to a jar file without adding it to the classpath is to put it in the ext subdirectory of your jre/lib directory which is under your JDK installation. On my PC it is this directory:
    C:\j2sdk1.4.2\jre\lib\ext
    Any jar files in there will be automatically added to your class path.


    Associate Instructor - Hofstra University
    Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
    Jon Wilson
    Greenhorn

    Joined: Oct 15, 2003
    Posts: 14
    One of my favorite things to do is to write a simple shell script or batch script that will compile everything. So, you only have to set the classpath once -- when you create the compile script -- from that point on you just call the compile script.


    Mensa member, Certified bartender, Created the Internet (along with Al Gore), Speak 9 languages fluently (this includes pig latin), Spelling Bee Winner, 8th Grade Math Award, Can hold breath under water for more than 2 minutes
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: very new and very lost...