Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

very new and very lost...

 
Lee McKenney
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lee McKenney
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Lee McKenney
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I checked and it's typo in the message only.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

  •  
    Lee McKenney
    Greenhorn
    Posts: 7
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 7
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 280
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 13974
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Jon Wilson
    Greenhorn
    Posts: 14
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic