DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: compile error - servlet not found

  1. #1
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    35

    compile error - servlet not found

    Please can somebody help. I've been batteling with this for days,

    I want to run my first servlet program so I have downloaded Tomcat (works fine). Then I wrote a simple .java file. When I try to compile this I get a compile error saying that packets javax.servlet and javax.servlet.http do not exist. I've looked over some old posts on this forum and they say I should have a servlet.jar file but when I look in my JDK 1.4 I only find the following .jar files

    imqservlet.jar
    jnlp-servlet.jar

    the java website seems to say that jnlp-servlet is the correct file. If so, what do I do now ? I've tried putting jnlp-servlet.jar in the same folder as my java file and the javac compiler but when I compile I get the same compile errors !

    Now I'm thinking I may have to change my path value in the environment variables, currently it is

    c:\Documents and Settings\home\desktop\bin;x[]#

    Its true I installled jdk1.4 on my desktop and it put a folder called bin there but ;x[]# is complete nonsense, or is it?

    If anybody can see whats going on here it would be great, this is driving me nuts.

    PS I apologise as I know similar questions to this have already been answered on this forum already but if somebody could just point out where I might be going wrong it would help a lot

  2. #2
    Join Date
    Dec 2005
    Posts
    48

    Put jar files to lib

    Put jar files to
    web-info/lib

  3. #3
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    35
    Thanks for your reply jetbrains,

    There are so many web-inf folders. Should there be a web-inf folder in the jdk folder somewhere. I notice that each of the following directories hold a web-inf folder

    jdk\samples\jnlp\cobra
    jdk\samples\jnlp\raf
    jdk\samples\jnlp\webpad

    do I need to create a new web-inf folder inside a new folder to hold my servlet ?

  4. #4
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    62
    The web-inf folder exists in Tomcat not in the JDK. Also servlet.jar exists within Tomcat somewhere (possibly a lib folder). The reason you cannot compile your servlet is because it is not in the classpath. Find servlet.jar and then create an environment variable called CLASSPATH which has the value of the location of the jar file, e.g.
    CLASSPATH=C:\Tomcat\.......\lib\servlet.jar

    Kind regards,
    Noel

    PS you can have as many locations as you want in CLASSPATH, just seperate the entries with a : in windows or a ; in Linux.

  5. #5
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    35
    Thanks noelob,

    I've been looking in the jdk all along. I found a servlet-api.jar file in tomcat and pointed the CLASSPATH variable to that and hey presto my java file has finally compiled.

    Thanks for your help

Similar Threads

  1. Java Mail Error
    By ddsuresh in forum Java
    Replies: 1
    Last Post: 12-29-2005, 10:58 AM
  2. Replies: 7
    Last Post: 11-30-2005, 09:49 AM
  3. HELP!!cannot compile codes
    By wahwgg in forum Java
    Replies: 0
    Last Post: 03-30-2003, 04:36 AM
  4. Replies: 0
    Last Post: 01-27-2001, 03:29 PM
  5. Compiling error - A package not found
    By Saiful in forum Java
    Replies: 3
    Last Post: 10-04-2000, 04:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center