Results 1 to 6 of 6
  1. #1
    wes
    wes is offline Member
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default Please help 'package javax.servlet does not exist'

    Hi All,

    I am having some issues and need help. I am new at Java developement and need to do an assignment. My Virtual has the following:

    - Tomcat 5.5
    - jdk 1.5.0_02
    - Textpad

    I have heard that there are better IDE's but not interested as Textpad is plain and simpel to me for what I need to do.

    Now the problem I am getting when importing javax.servlet.* I get the following when compiling
    - package javax.servlet does not exist
    - cannot find symbol symbol: class HttpServlet

    I did research and all says that the classpath needs to change to point to 'C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar'
    so I took the steps to do this but then I get another error 'Exception in thread "main" java.lang.NoClassDefFoundError: myTest'.

    Can anyone please tell me how would be the simplest to get around this and what am I missing??


    Kind regards,

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    What's the full exception thrown?

  3. #3
    wes
    wes is offline Member
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default

    C:\Documents and Settings\BPUser\Desktop\test.java:2: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    C:\Documents and Settings\BPUser\Desktop\test.java:4: cannot find symbol
    symbol: class HttpServlet
    public class test extends HttpServlet
    ^
    2 errors

    Tool completed with exit code 1

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default

    I did research and all says that the classpath needs to change to point to 'C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar'
    so I took the steps to do this but then I get another error 'Exception in thread "main" java.lang.NoClassDefFoundError: myTest'.
    You need both the jar and the current working directory on the classpath. Add a ".;" (windows) or ".:' (*n[ui]x) ahead of the path to the jar.

    That's "dot semicolon" or "dot colon" in case the punctuation characters are hard to read.

    db

  5. #5
    wes
    wes is offline Member
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default

    Darry thanks for the reply.

    Am I correct then in my example below from command prompt?

    set CLASSPATH="[SourceFile Directory]".;"[Dir]\api-servlet.jar"

    Thanks,

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default

    There's no need to 'set CLASSPATH' you can just pass the class path to the -cp flag.

    db

Similar Threads

  1. package javax.swing does not exist
    By timosoft in forum AWT / Swing
    Replies: 5
    Last Post: 02-15-2011, 01:17 AM
  2. javax.servet.* does not exist
    By junaidsherief in forum Java Servlet
    Replies: 2
    Last Post: 09-20-2010, 10:18 PM
  3. package javax.servlet does not exist :>
    By wildheart25c in forum Java Servlet
    Replies: 2
    Last Post: 02-17-2010, 12:02 AM
  4. package javax.servlet does not exist
    By nikhil2jan in forum Java Servlet
    Replies: 1
    Last Post: 01-04-2009, 04:32 PM
  5. package mj does not exist
    By PzK in forum New To Java
    Replies: 8
    Last Post: 12-03-2008, 10:30 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
  •