Classpath set BUT still javax.servlet package not found when compiling

Hello,
I'm trying to compile a servlet and use tomcat 5 to run it. After I set the classpath to include the servlet-api.jar file, the compiler still tells me it cannot find package. I'm not sure what else to do. Please Help.
Thanks Smoker

Then you haven't set the actual classpath that the compiler is using. Just because you say you have set the 'classpath' doesn't mean you've properly told the compiler that.
Such as, what did you do, set the CLASSPATH environment variable? Don't do that - ever. If that's what you did, and you're using an IDE, the IDE project is ignoring that environment variable anyway. You have to configure the project appropriately (which for one thing sets up the 'classpath' it uses), which varies depending on the IDE. That's an IDE question though, not a Java one.

Similar Messages

  • Servlet package not found

    I am trying to compile a servlet and i keep getting the error 'servlet package not found' I went and downloaded the servlet package but am unsure how to implement. I assume the i would need to ammend the classpath or path, but not sure. If someone could give some simple instructions, I'd be grateful.

    hi,
    as mentioned you will have to add the servlet package to the classpath environment variable.
    lez say the java servlet class files are present in the servlet.jar file.. herez how u would add it to the classpath ..
    set CLASSPATH=%CLASSPATH%;<path-to-jar>\servlet.jar;.
    Therez a dot at the end of the classpath (this puts the current directory in the CLASSPATH)
    you would have to replace the <path-to-jar> with the actual location for eg
    set CLASSPATH=%CLASSPATH%;c:\java\servlets\lib\servlet.jar;.
    hope this helpz
    cheerz
    ynkrish

  • Javax.servlet.* Not Found Error - Please help

    I am having a great deal deal of trouble trying to compile a program using javax.servlet and javax.servlet.hhtp.*. I have setup the JAVA_HOME and the CLASSPATH variables as per the Installation instructions. I appear to have hit a brick wall and I am absolutely desperate to get this working. I have installed the J2EE SDK as well as the Servletapi2.1. Please Help.
    Variables:
    CLASSPATH=c:\jdk1.3\lib\tools.jar;c:\j2sdkee1.3.1\lib\j2ee.jar;c:\jdk1.3\jre\bin;c:\jdk1.3\jre\lib;c:\mm.mysql-2.0.14\org;c:\jdk1.3\lib\servlet.jar;
    JAVA_HOME=c:\jdk1.3;
    J2EE_HOME=c:\j2sdkee1.3.1;
    PATH=%PATH%;c:\jdk1.3\bin;c:\j2sdkee1.3.1\bin;
    Error message from compiler:
    L:\PROGRA~1\allaire\jrun\servers\default\loanstest\web-inf\classes\PasswordServlet.java:27: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    L:\PROGRA~1\allaire\jrun\servers\default\loanstest\web-inf\classes\PasswordServlet.java:30: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    L:\PROGRA~1\allaire\jrun\servers\default\loanstest\web-inf\classes\PasswordServlet.java:39: cannot resolve symbol
    symbol : class HttpServlet
    location: class PasswordServlet
    public class PasswordServlet extends HttpServlet

    I can only think of three suggestions.
    One, use your mouse to "cut-n-paste" the value of CLASSPATH and verify that those files are exactly where you think they are, and are spelled right.
    E.g.
    CD C:\JDK1.3\LIB
    DIR SERVLET.JAR
    Two, if they're spelled right, run "jar tvf" on the files to make sure they aren't corrupted or something.
    E.g.:
    JAR TVF SERVLET.JAR
    Three, since you're working in Windoze, try putting the value inside double quotes. E.g.:
    SET CLASSPATH="c:\jdk1.3\lib\tools.jar;c:\j2sdkee1 ... etc ... "
    If you haven't tried the above, give it a go, see what happens.

  • Servlet package not found error

    I am getting the following error while running my servlet .I have servlet.jar,servlet-api.jar,servlet-2_5-api in my lib directory.Do i have to give path for .jar files??
    C:\j2sdk1.4.2_02\bin>javac PostParameterServlet.java
    PostParameterServlet.java:3: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    PostParameterServlet.java:6: cannot resolve symbol
    symbol  : class GenericServlet
    location: class PostParameterServlet
    class  PostParameterServlet extends GenericServlet
                                        ^
    PostParameterServlet.java:8: cannot resolve symbol
    symbol  : class ServletRequest
    location: class PostParameterServlet
            public void service(ServletRequest req,ServletResponse res)throws ServletException,
    IOException
                                ^
    PostParameterServlet.java:8: cannot resolve symbol
    symbol  : class ServletResponse
    location: class PostParameterServlet
            public void service(ServletRequest req,ServletResponse res)throws ServletException,
    IOException
                                                   ^
    PostParameterServlet.java:8: cannot resolve symbol
    symbol  : class ServletException
    location: class PostParameterServlet
            public void service(ServletRequest req,ServletResponse res)throws ServletException,
    IOException
                                                                              ^
    5 errorsand here my code
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    class  PostParameterServlet extends GenericServlet
         public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException
              PrintWriter pw=res.getWriter();
              Enumeration e=req.getParameterNames();
              while(e.hasMoreElements())
                   String pname=(String)e.nextElement();
                   pw.print(pname +"=");
                   String pvalue=req.getParameter(pname);
                   pw.println(pvalue);
              pw.close();
    }

    Sun_Rockz wrote:
    C:\Suraj\jspproj\beerV1>javac -classpath "c:\apache software foundation\tomcat 5
    .5\common\lib\servlet-api.jar;classes" -d classes src\com\example\web\beerselect
    .javaYou've quoted the classpath the wrong way. Only quote the separate paths, not all paths together, it would be seen as a single path otherwise.

  • Javax.servlet.* not found

    I am importing a package called
    import javax.servlet.*;
    but it shows me error that it doesnt find this package ..
    I have searched the src.zip file, it contains the javax folder but the javax folder doesnt contain the servlet folder inside it. please help me wut shud i do

    Hi,
    You have to put servlet.jar in your classpath. If you are using Tomcat it is in common/lib folder of tomcat directory. Hope this will help.
    Regards
    Sekhar

  • Javax.smartcardio package not found in Java source file

    I downloaded the latest JDK from developer.apple.com, but now I cannot find the javax.smartcardio package in the source package (src.jar) that came with it. I unpacked the JAR file, but simply can't find the stated package. Can you help me out?

    I can confirm the issue here (Mountain Lion, 10.8.5). A very simple program (attached below) that just enumerates terminals and checks if a card is present will crash:
    If Apple JDK6 is used in 64-bit mode (without supplying the -d32 argument)
    If Oracle JDK7 is used (can not switch to 64-bit, uses)
    It will work if:
    If Apple JDK6 is forced into 32-bit mode using -d32
    If Oracle JDK7 version of libj2pcsc.dylib is replaced with a patched version
    javax.smartcardio on Mac OS X is in a truly sad state. :-(
    Can anyone suggest alternatives for Smartcard communication on Mac OS X fat clients?
    package com.example.smartcardio;
    import javax.smartcardio.CardTerminal;
    import javax.smartcardio.CardTerminals;
    import javax.smartcardio.TerminalFactory;
    public class TestWaitForChanges {
              public static void main(String[] args) throws Exception {
                        CardTerminals terminals = TerminalFactory.getDefault().terminals();
                        while (true) {
                                  for (CardTerminal terminal : terminals.list()) {
                                            System.out.println("Checking terminal: " + terminal.getName());
                                            System.out.println("Card present: " + (terminal.isCardPresent() ? "YES" : "NO"));
                                  System.out.println("Waiting for changes...");
                                  terminals.waitForChange();

  • Package not found when nested

    When I tried to make packages in this way:
    ApplicationProgram (import TalepDurum.gui.Kurumlar.*;)
    TalepDurum(package)
    --gui(package)
    | --Kurumlar(package)
    |
    --TalepType(package)
    and I tried to reach the Kurumlar package from the
    ApplicationProgram, then it gives an error
    saying that no such a package or classpath not found.
    Anyone who understand the problem? Thanks for help...

    This might help.
    http://java.sun.com/docs/books/tutorial/java/interpack/packages.html
    If you have a directory structure of TalepDurum/gui/Kurumlar and the directory that contains TalepDurum is in your Classpath when you compile, then it will work.

  • Package not found when importing in JSP

              I'm now using Weblogic 6.0 SP 2 for development. I did a test application, containing
              EJBs, and a JSP. Package the applications to an EAR file. Then I deploy the test
              application using hot-deploy - just drop the EAR into the domain\application folder.
              When I call the JSP page, I get an error saying that the package I'm importing
              is not found. What is wrong?? The test application works on Weblogic 5.1
              My WAR file contains only the JSP and XML descriptor. Do I need to include classes
              inside??? Don't think that is correct.
              Please advise.
              

              It was a bad mistake. Made an error in the application.xml, which refer to an invalid
              JAR file. Made the correction and it works like magic.
              Thanks :)
              "Cameron Purdy" <[email protected]> wrote:
              >WL 60 is tolerant of class location in that you can put all classes in
              >the
              >EJB JAR inside the EAR and it will work as well (sometimes better if
              >there
              >are xrefs) as carefully splitting classes between JAR and WAR.
              >
              >Chances are your context is not set up correctly. What is the web.xml?
              >What
              >is the URL you used? In WL 51 you provided the context in the "register"
              >line in the weblogic.properties. Now that info is self-contained in the
              >app
              >itself.
              >
              >Peace,
              >
              >--
              >Cameron Purdy
              >Tangosol Inc.
              ><< Tangosol Server: How Weblogic applications are customized >>
              ><< Download now from http://www.tangosol.com/registration.jsp >>
              >
              >
              >"Moong" <[email protected]> wrote in message
              >news:[email protected]...
              >>
              >> I'm now using Weblogic 6.0 SP 2 for development. I did a test application,
              >containing
              >> EJBs, and a JSP. Package the applications to an EAR file. Then I deploy
              >the test
              >> application using hot-deploy - just drop the EAR into the
              >domain\application folder.
              >>
              >> When I call the JSP page, I get an error saying that the package I'm
              >importing
              >> is not found. What is wrong?? The test application works on Weblogic
              >5.1
              >>
              >> My WAR file contains only the JSP and XML descriptor. Do I need to
              >include
              >classes
              >> inside??? Don't think that is correct.
              >>
              >> Please advise.
              >>
              >
              >
              

  • Classes not found when compiling for jdk1.3.1_01 on red hat 7.2

    I have just installed jdk1.3.1_01 (rpm) on linux red hat 7.2
    I have written a small program to test, however, the compiler isn't able to locate the classes.
    import javax.swing.*;
    public class JTest {
    public static void main( String args[] )
    JOptionPane.showMessageDialog( null, "Hello", "Test Dialog",
    JOptionPane.INFORMATION_MESSAGE );
    System.exit( 0 );
    When compiled it generates the error:
    JTest.java:10: error:Variable "JOptionPane" is not defined in current context
    I have the path and classpath set to what I think are the correct directory paths.
    Any advice would be much appreciated!
    Thanks..

    Sorry, typo in the classpath... but now when I compile
    I get error: "segmentation fault" then nothing else.
    This also happens when I execute a precompiled app (eg
    "java OldApp").This is to do with GLIBC-2.2, I believe. :/ (Pointed out by Niteen. :)
    "ulimit -s 2048" should fix this. Adding this line to /etc/profile or your ~/.profile shall automatically run this command every log in.
    Bhav

  • Python headers not found when compiling gimp2.7

    Hello. I am trying to compile gimp 2.7 and when I run configure I get an error "python headers not found". I've read that in arch you get the headers together with the rest of the package so there is no need for a -dev package. I have installed python several times with pacman, but the problem persists.

    Edit the PKGBUILD and insert this:
    PYTHON=python2 PYTHON_VERSION=2.7
    infront of the "./configure" part. So it looks like this:
    PYTHON=python2 PYTHON_VERSION=2.7 ./configure --prefix=/usr --- snip ---
    happy compiling

  • Library -lc: not found when compiling ncurses 5.7 in solaris 10

    Hi,
    I'm using Solaris 10 x86_64 and I am having problems compiling ncurses 5.7. This is the error message when I try to execute make:
    gcc ../objects/tic.o ../objects/dump_entry.o -I../progs -I../../progs -DHAVE_CONFIG_H -I../../progs/../include -I. -I../include -D__EXTENSIONS__ -D_FILE_OFFSET_BITS=64 -DNDEBUG -I/usr/local/include/ncurses -O2 --param max-inline-insns-single=1200 -static -L../lib -lncurses -L../lib -lncurses -dynamic   -o tic
    ld: fatal: library -lc: not found
    ld: fatal: File processing errors. No output written to tic
    collect2: ld returned 1 exit status
    make[1]: *** [tic] Error 1
    make[1]: Leaving directory `/Documents/ncurses-5.7/ncurses-5.7/objdir/progs'
    make: *** [all] Error 2
    I've read that this error happens because you cannot statically compile with the c library in Solaris and that this is not exactly an ncurses bug. I am quite new to Solaris and I do not understand this entirely? Can anyone help me fix this? And perhaps give some explanation as well?
    Your help would be much appreciated.

    I'm not familiar with all the variations here, but I suspect gcc may be erroring out saying that it doesn't have a static copy of libc, Correct, from the truss output:
    7060:     open("/opt/local/lib/libc.a", O_RDONLY)          Err#2 ENOENT
    7060:     open("/usr/sfw/lib/libc.a", O_RDONLY)          Err#2 ENOENT
    7060:     open("../lib/libc.a", O_RDONLY)               Err#2 ENOENT
    7060:     open("../lib/libc.a", O_RDONLY)               Err#2 ENOENT
    7060:     open("/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/libc.a", O_RDONLY) Err#2 ENOENT
    7060:     open("/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/../../../../i386-pc-solaris2.11/lib/libc.a", O_RDONLY) Err#2 ENOENT
    7060:     open("/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/../../../libc.a", O_RDONLY) Err#2 ENOENT
    7060:     open("/usr/ccs/lib/libc.a", O_RDONLY)          Err#2 ENOENT
    7060:     open("/lib/libc.a", O_RDONLY)               Err#2 ENOENT
    7060:     open("/usr/lib/libc.a", O_RDONLY)          Err#2 ENOENT
    7060:     open("/usr/sfw/lib/libc.a", O_RDONLY)          Err#2 ENOENT
    # find / -name libc.a
    There's also a possibility of problems with templates:
    7058:     access("/usr/ccs/bin/ld.rpo", R_OK)          Err#2 ENOENT
    7058:     access("P,/usr/ccs/lib:/lib:/usr/lib:/usr/sfw/lib.rpo", R_OK) Err#2 ENOENT
    7058:     access("/usr/ccs/lib:/lib:/usr/lib:/usr/sfw/lib.rpo", R_OK) Err#2 ENOENT
    7058:     access("tic.rpo", R_OK)                    Err#2 ENOENT
    7058:     access("/usr/lib/crt1.rpo", R_OK)          Err#2 ENOENT
    7058:     access("/usr/lib/crti.rpo", R_OK)          Err#2 ENOENT
    7058:     access("/usr/lib/values-Xa.rpo", R_OK)          Err#2 ENOENT
    7058:     access("/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/crtbegin.rpo", R_OK) Err#2 ENOENT
    7058:     access("../objects/tic.rpo", R_OK)          Err#2 ENOENT
    7058:     access("../objects/dump_entry.rpo", R_OK)     Err#2 ENOENT
    7058:     access("/usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/crtend.rpo", R_OK) Err#2 ENOENT
    7058:     access("/usr/lib/crtn.rpo", R_OK)          Err#2 ENOENT
    while Studio 12 may be falling back to dynamic linkages for libraries where it doesn't have a static copy.Studio 12
    truss -f -o /tmp/out gmake
    grep libc.a out
    all show ENOENT
    There shouldn't be a problem with having the application libraries static, but the OS libraries will not be.:-)
    alan

  • Java.lang symbols not found when compiling package classes

    I have a set of classes that I have wrapped up in a package. The package name and
    directory structure follow the standard required for each. These classes contain many
    java.lang.Math functions and java.lang.Double calls.
    Am I correct in that the java.lang functions will be imported automatically? When I
    compile a class that is in the package, it looks for the Math.pow (for example)
    function in the package instead of java.lang. I have tried putting the following include
    at the top:
    include java.lang.*;and I still get the "cannot resolve symbol" error. Only when I use
    include java.lang.Math;
    include java.lang.Double;does it compile properly. Is this indicative of a problem with my classpath? It is
    currently set to look in whatever the current directory is, the directory with src.jar,
    and my dev directory that contains the package I am working on.
    Please advise! Thanks in advance!
    Rodman

    Thanks for the quick reply! I looked in the package directory and found the Math.java and
    Double.java files. I'm not sure why they were there. Thanks again!

  • Often "package not found" when updating from mirrors.

    This seems to be some defect in mirror sync mechanism, since they declare package as already synced, but in fact they don't have it.
    It occurs so often and is really annoying. I have to use main server when this happens.
    I believe this is a bug and Arch needs a better method of mirrors syncing.

    pyther wrote:
    My understanding of the packing process is that all testing packages are in a folder called testing-x86_64 or testing-i686 depending on the arch. Then when a package gets moved, it gets moved to extra-i686 or extra-x86_64.
    So then on the mirror the pkg is being deleted from testing and being uploaded to extra. This seems to kill many of the mirrors.
    Maybe a dev can shed a bit more lite on this topic.
    That is exact. For example, the latest libpng/libjeg rebuild had over several GB of packages to be upload to all the mirrors when it was pushed to extra/community.  Therefore, you have lots of packages and lots of mirrors so there's not enough rsync connections and/or bandwith to get the package to the mirrors fast enough. Plus the main server still has to serve web pages for the main web site, the forums, wiki, etc.
    We are aware of the problem and got a patch to fix this (see dev ML). Basically, the packages will go in a pool and we'll use symlinks like we're doing for the 'any' arch. Instead of moving packages around, we'll be moving symlinks.  As they are much smaller, it'll be faster.

  • Javax package not found

    Hi,
    I installed jdk1.4 in my system.And i type one swing concept program.After compilation of that program.It shows error like Javax.Swing. package not found.Please help to me to clear the proble.And also Javax.servlet package also not taken.
    regards
    sridhar

    Its javax, not Javax.

  • Package javax.servlet does not exist, package javax.servlet.http does not

    Dear All,
    I am a newbie to JAVA.
    I installed JDK1.6.0_04, then NetBeans IDE 6.0
    I tried compiling an example servlet, but got this error message:
    package javax.servlet does not exist, package javax.servlet.http does not exist
    I tried locating these packages, but in vain. I also tried setting the CLASSPATH to many values, still it did not work.
    Can anyone, please, help me with this.
    Should I be able to see/locate these packages, do I have to download them?
    Thank you very much.

    davidgoodman wrote:
    Dear All,
    I am a newbie to JAVA.
    I installed JDK1.6.0_04, then NetBeans IDE 6.0
    I tried compiling an example servlet, but got this error message:
    package javax.servlet does not exist, package javax.servlet.http does not exist
    What servlet/JSP engine do you plan to deploy to? Tomcat, perhaps?I think it's Tomcat (C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14). Are there other engines that come with NetBeans IDE 6.0 (when I downloaded NetBeans, I chose ALL)
    >
    If so, you'll need to put the servlet JAR in your CLASSPATH. (servlet-api.jar for Tomcat 5.5 and earlier, servlet.jar for 6.0 >and later.)
    I tried locating these packages, but in vain.
    You won't find them until you realize that you have to deploy that servlet someplace.How to deploy?
    I also tried setting the CLASSPATH to many values, still it did not work.
    See above. What were you planning to set CLASSPATH to?First I set to:
    C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib (because I found jar named servlet-api.jar in this folder)
    Later I added this:
    C:\Program Files\Java\jdk1.6.0_04\lib (out of trial-and-fail)
    Finally I added some paths that lead to a library such as
    C:\Program Files\glassfish-v2\lib
    C:\Program Files\glassfish-v2\lib\ant\lib
    Can anyone, please, help me with this.
    Should I be able to see/locate these packages, do I have to download them?
    You have to get a servlet/JSP engine. Step 1.Thank you for your help

Maybe you are looking for

  • Journal Reports - SSRS

    Experts -  If you have Journals enabled in an Application, you can go into BPC for Excel, and open up Journals (eTools...Journal), which opens up the eJournals menu. Then you can go into eJournal...Reports, and you'll find three reports to choose fro

  • OBPM process start after UCM check in

    Hi People, I have a problem in my hand like this. When I check in a document in Oracle UCM a process in Oracle BPM needs to be triggered. This is not synonymous to invoking a BPEL workflow I think. Because I want to publish the document in ucm straig

  • Taking a screenshot while touching the screen with iOS6

    Hello, Ever since I updated my iPhone 4S to the new iOS6 I noticed I can't take screenshots while touching the screen, for example - if I want to take a screenshot of a text message while rolling up the screen (so that only a certain part of the scre

  • Source list & quota arrangement

    At which level the source list is maintained: Client Level Plant Level Purchasing Org. level When source determination takes place, does the quota arrangement takes precedence over a fixed vendor?

  • How to move Address Book from iBook to MacBook

    I used migrate to transfer everything from my iBook (OSX.2.8) to new MacBook. Mail is working but missing all of my old addresses in Mail. How do I transfer them to my new MacBook?