Trouble compiling servlets with J2SE 5

Hello,
I've been using Sun 1 Studio CE, and more recently, Netbeans 3.6, with J2SE 1.4.2. I have some basic swing applets and servlets that I wrote for my business' web site.
I recently downloaded and installed the new software bundle containing Netbeans 4.0 and J2SE 1.5. When I try to compile my servlets, I get a compiler error that packages javax.servlet.* and javax.servlet.http.* do not exist.
I reinstalled J2SE 1.4.2 and Netbeans 3.6 and the servlets compile fine.
Why is JDK 5 not able to find these packages? My understanding is that they're part of the Java Servlet API, which I never explicitly downloaded previously. Is that the piece of the puzzle that I'm missing? Please help!
Thanks

Thanks for your response...
What is interesting is that I never explicitly installed the Servlet API. Out of curiosity, I searched my computer for servlet*.jar and came up with 13 files including:
servlet-2.2.jar
servlet-2.3.jar
servlet-api-2.4.jar
These were located in subdirectories under Netbeans 3.6 and Tomcat 5.0.19. Therefore, I'm assuming that when I downloaded the JDK 1.4.2/Netbeans 3.6 bundle from the Java site, the Servlet API must have been part of the bundle.
****Let me check something...***
I've just done the same search for servlet*.jar on my test PC, which has the Netbeans 4.0/JDK 5 bundle installed. The same files exist, in the same locations(almost the same, anyway; the Tomcat and Netbeans 4 directory structures are a little different).
Both software bundles contain the same files, yet 1.4.2 compiles without any problems or additional configuration. In other words, I reinstalled the old 1.4.2/ Netbeans 3.6 bundle, took my existing source code, and started compiling.
Any ideas why the same isn't true for JDK 5/Netbeans 4? I know there are changes to the way Netbeans 4.0 deals with Class Paths, but I thought that was for the classes I've written. Shouldn't the compiler be able to find the servlet API, since it bundled/installed with everything else?
Thanks

Similar Messages

  • Can I compiler servlet with java compiler?

    Can I compiler servlet with java compiler?
    Here is an example of it:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class HelloWorldServlet extends HttpServlet
              protected void doGet(HttpServletRequest request,
              HttpServletResponse response) throws ServletException , IOException
                        response.setContentType("text/html");
                        PrintWriter out = response.getWriter();
                        StringBuffer sb = new StringBuffer();
                        sb.append("<html><body><h1>");
                        sb.append("Hello World");
                        sb.append("</h1></body></html>");
                        out.print(sb.toString());
                        out.close();
         }

    Can I compiler servlet with java compiler?
    yes.
    just include the correct jarfiles in your classpath.

  • Trouble compiling servlet example

    Hi All, I am trying out an example for servlets and I ran into trouble compiling the the file called "FormProcessingServlet.java" in tutorial located here: http://developer.java.sun.com/developer/onlineTraining/Servlets/Fundamentals/magercises/FormPostingAndProcessing/index.html
    The exact problem happens in this line:
    isStructure = context.getResourceAsStream(paramStructureFile[0]);
    The error says:
    FormProcessingServlet.java:127: cannot resolve symbol
    symbol : method getResourceAsStream (java.lang.String)
    location: interface javax.servlet.ServletContext
    isStructure = context.getResourceAsStream(paramStructureFile[0]);
    anyone else ran into this problem? How do I fix this? Thanks.

    "cannot resolve symbol" means that the JVM can't find a particular class.
    Adjust your systems classpath variable to include all the jar files that you use, I also add "." to include files in the current directory I'm working from.

  • Compiling servlet with helper class

    Hello,
    I have to write a very large number of database queries and huge amount of code so I decided to make each helper *.class file for each table.
    Now I have a main servlet that should instantiate each of these helper classes and conduct DB operations:
    //Servlet code
    RescardreservationTable rv = new RescardreservationTable();
    rv.insertInfo();
    RescardPassengerTable rp = new RescardPassengerTable();
    rp.insertInfo();RescardreservationTable.class
    //does DB opsMy problem is that when I try to compile servlet, I get
    insert_data.java:172: cannot find symbol
    symbol : class RescardreservationTable
    location: class insert_data
    RescardreservationTable rv = new RescardreservationTable();
    Could somebody please tell me how I can make servlet locate my java classes that it has to use?
    Thanks,
    Victor.
    Edited by: vic_sk on Dec 9, 2008 9:29 AM

    Ok, looks like it's solved. Just forcing the compiler with -classpath to look for the required class file.

  • Trouble compiling package with JDK 1.4

    Hi,
    I just installed JDK 1.4 on a new machine, now I have trouble running compile scripts that used to work on my old machine. The old an new are configured with Win 2000. The following compiles without problem:
    javac -classpath "..." -d "..." "c:\.....\com\...\some package\MyClass.java"
    Changing this statemetn to:
    javac -classpath "..." -d "..." "c:\.....\com\...\some package\*.java"
    should compile all Java files in 'some package', instead what I get is the following error message:
    error: cannot read: c:\.....\com\...\some package\*.java
    The documentation says that this should still work. Anyone aware of changes in 1.4 that could cause this problem?
    Thanks for responding

    As a work-around, you can use some Unix-styled shell (that is, command processor) which expands the *.expression into the list of the matching file names, thus releaving javac from this task. (Caveat: directory names with a space inside will cause problems.)
    I can recommend the Cygnus package (including the command processor "bash") or "MinGW", the Minimalist GNU For Windows with its simpler sh:
    http://www.mingw.org/
    ftp://ftp.franken.de/pub/win32/develop/gnuwin32/mingw32/porters/Mikey/

  • Trouble compiling Servlets... simple problem?

    PATH: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\PROGRA~1\ULTRAE~1;C:\j2sdk1.4.0\bin;C:\j2sdkee1.3.1\bin
    CLASSPATH: C:\j2sdkee1.3.1\lib\j2ee.jar;C:\j2sdkee1.3.1\lib\j2eetool.jar
    Yet for some reason I can't compile anything using the servlet packages. I had been able to compile in the past, but I added a new value to the PATH and CLASSPATH variables to try to get Tomcat4.0.1 to work, and then this morning I ceased to be able to compile. So I went back to my old values and can't compile! (DataServlet.java:3: package javax.servlet does not exist
    import javax.servlet.*; )
    Please help. Thank you.

    Ok, I just wrote this post, closed the command prompt I was trying to compile in, reopened another, and tried to compile again and it worked. Can someone tell me what this is about?

  • How to compile servlet with Edit Plus?

    Hi
    I am writing a Java servlet in EditPlus and am wondering how to include the servlet.jar file so that EditPlus knows where the javax.servlet.*, etc classes are. I suppose this is an EditPlus specific question so sorry about that but I didn't know who else to ask other than EditPlus themselves of course and I think I have tried that once.
    I have read replies on this forum about changing the classpath but I dont think that that is what I need to do here and if it is I dont know what I should be writing as I am not using the jdk.
    If anyone can help me at all I would be very grateful.
    Thanks

    Yes, I have also compiled Java files from EditPlus. Using the facilities for configuring 'User Tools' in EditPlus.
    EditPlus runts programs(javac in the current context) in a separate environment(separate DOS command).
    I just compiled, from EditPlus, some Java file of mine that uses something from the servlet API. It compiled just fine. I did not do any classpath or other setup on classpath lines inside EditPlus. I guess, EditPlus inherits the existing CLASSPATH(all environment settings in fact) setting from your environment and thereafter aslo passes it along to the separate command prompt it opens to run user configured tools to run.

  • Compiling a servlet with utility class

    Hello,
    I am having trouble compiling a servlet that uses a utility class.
    The compiler doesn't seem to recognize the utility class for some reason.
    my classpath is set to:
    .;C:\ServletDevel;C:\Program Files\Apache Software Foundation\common\lib\servlet-api.jar
    the error:
    Cannot find symbol: ServletUtilities
    the servlet code:
    package coreservlets;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    /** test the use of packages and utilities on the server */
    public class helloservlet3 extends HttpServlet {
    public void doGet(HttpServletRequest request,
                   HttpServletResponse response)
                   throws ServletException, IOException {
         response.setContentType("text/html");
         PrintWriter out = response.getWriter();
         String title = "Hello (3)";
         out.println(ServletUtilities.headWithTitle(title) +
              "<body bgcolor=\"#FDF5E6\">\n" +
              "<h1>" + title + "</h1>\n" +
              "</body></html>");
    the utility class:
    package coreservlets;
    import javax.servlet.*;
    import javax.servlet.http.*;
    /** time saving static methods */
    public class ServletUtilities {
         public final static String docType =
         "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
         "Transitional//EN\">";
    public static String headWithTitle(String title){
    return (docType + "\n" + "<html>\n" +
              "<head><title>" + title + "</title></head>\n");
    any help wouldbe greatly appreciated.

    Nope still getting an error
    helloservlet3.java:17:cannot find symbol
    symbol : class ServletUtilities
    location: package coreservlets
    out.println(coreservlets.ServletUtilities.headWithTitle(title) +
    thanks for the help, i'll keep on trying to figure it out.

  • Compiler problems with J2EE

    Hi,
    I�am only new to the J2EE platform but have experience with J2SE. I have installed J2EE 1.4 and Tomcat server 5.0.28 to study for the Web Component Developer Exam.
    When I go to compile my java files, the compiler doesn�t not recognise the J2EE parts of the file. I have imported the correct classes (even the import statements, it doesn�t recognise!) and when I compile, the errors are associated with J2EE classes (i.e. doesn�t recognise HttpServlet....)
    I compile in command prompt by typing: javac myFile.java.
    I am aware that the file servlet-api.jar is required for these J2EE extras when compiling and I think this is my problem. I have put the location of this file on my classpath (set classpath=.;C:\fileDir\servlet-api.jar) by it still fails to compile. I have also put this location of the file directly into my PATH by this doesnt help!
    Can anybody help me out with this configuration problem?
    Thanks very much for any help!

    You need to have j2ee.jar (which can be found in <j2ee_install_dir>/lib directory in your classpath in order to successfully compile.

  • Not Able to compile Servlet from ?

    Hi All,
    I am not able to compile Servlet from my package:
    1) I Have set the CLASSPATH Variable using below line in System Variables:
    C:\CC4\prog\jakarta-tomcat-4.1.30\common\lib\servlet.jar
    2) Also Set the CATALINA_HOME with value
    C:\CC4\prog\jakarta-tomcat-4.1.30
    as per above setting servlet should be compiled but still i m getting error message:
    1) C:\CC4\prog\jakarta-tomcat-4.1.30\project\classes\com\example>javac ListenerTest
    er.java
    ListenerTester.java:17: cannot resolve symbol
    symbol : class Dog
    location: class com.example.ListenerTester
    Dog dog = (Dog) getServletContext().getAttribute("dog");
    ^
    ListenerTester.java:17: cannot resolve symbol
    symbol : class Dog
    location: class com.example.ListenerTester
    Dog dog = (Dog) getServletContext().getAttribute("dog");
    ^
    2 errors
    2) Error while compiling other file:
    C:\CC4\prog\jakarta-tomcat-4.1.30\project\classes\com\example>javac MyServletCon
    textListener.java
    MyServletContextListener.java:12: cannot resolve symbol
    symbol : class Dog
    location: class com.example.MyServletContextListener
    Dog d = new Dog(dogBreed);
    ^
    MyServletContextListener.java:12: cannot resolve symbol
    symbol : class Dog
    location: class com.example.MyServletContextListener
    Dog d = new Dog(dogBreed);
    ^
    2 errors
    So what could be the posible solution here :
    do reply !!!
    please
    Thanks
    prabhat

    I have added servlet.jar in the classpath. But the program is not compiling.The error message says that it can not find classes like ServletConfig, ServletException, Cookie etc. Please help.

  • Trouble compiling for printed documentation

    hello, i am having trouble compiling a new document layout i
    have created, i have followed peter grainges instructions on his
    website but it always fails to generate straight away. Im using
    Robohelp x5 with word 2000, does anyone have any ideas?
    thanks steve

    Steve
    Was RH installed on the PC you are using with you logon or
    that of the person whose job you have taken over? It sounds very
    much like the latter and this is exactly what I would expect to
    happen.
    Try creating a new project with just a couple of topics and
    printing from that. It will likely also fail. If it does that
    pretty much confirms my theory. Uninstall and reinstall RH with
    your logon and with admin rights attached and the problem will
    likely go away.

  • Trouble compiling a library

    Hi folks, I'm experiencing a trouble using forms & reports on two different platforms: Win XP Prof. SP2 for development and SuSe Ent. 9 Linux for deployment.
    I've inherited from another person an application with some forms, some reports and two libraries (one attached to the forms annd the other attacched to the reports).
    I've modified a function in the library attacched to the reports. It compiles ok on XP.
    Moved the library (.pll file) to Suse I tried to compile with:
    #!/bin/sh
    PATH_SAVE=$PWD
    ORACLE_HOME=/opt/oracle/app/oracle/product/frs10.1.2
    export ORACLE_HOME
    FORMS_PATH=/opt/csa/sw/webapp/FORMS:/opt/csa/sw/webapp/CSA_LIBS
    export FORMS_PATH
    REPORTS_PATH=/opt/csa/sw/webapp/REPORTS:/opt/csa/sw/webapp/CSA_LIBS
    export REPORTS_PATH
    TNS_ADMIN=$ORACLE_HOME/network/admin
    export TNS_ADMIN
    TWO_TASK=csa_v30/csa_v30@csa5i009
    export TWO_TASK
    ORACLE_SID=csa5i009
    export ORACLE_SID
    LD_LIBRARY_PATH=$ORACLE_HOME/jdk/jre/lib/i386/server:$ORACLE_HOME/jdk/jre/lib/i386/native_threads:$ORACLE_HOME/jdk/jre/lib/i386:$ORACLE_HOME/lib
    export LD_LIBRARY_PATH
    ORACLE_TERM=vt220
    export ORACLE_TERM
    # COMPILE LIBRARIES
    cd /opt/csa/sw/webapp/CSA_LIBS
    $ORACLE_HOME/bin/frmcmp_batch module=LIB_CSA_FORMS.pll userid=csa_v30/csa_v30@csa5i009 module_type=LIBRARY compile_all=YES logon=YES batch=YES
    # COMPILE FORMS and MENUS
    cd /opt/csa/sw/webapp/FORMS
    for file in *.fmb
    do
    $ORACLE_HOME/bin/frmcmp_batch module=$file userid=csa_v30/csa_v30@csa5i009 module_type=FORM compile_all=YES logon=YES batch=YES
    done
    for file in *.mmb
    do
    $ORACLE_HOME/bin/frmcmp_batch module=$file userid=csa_v30/csa_v30@csa5i009 module_type=MENU compile_all=YES logon=YES batch=YES
    done
    cd $PATH_SAVE
    unset PATH_SAVE
    and obtained:
    PL/SQL ERROR 201 at line 58, coloumn 5
    identifier 'SRW.SET_FOREGROUND_FILL COLOR' must be declared
    FRM-30312: Failed to compile the library
    Some useful data:
    Forms [32 Bit] Version 10.1.2.0.2 (Production)
    Oracle Toolkit Version 10.1.2.0.2 (Production)
    PL/SQL Version 10.1.0.4.2 (Production)
    Oracle Procedure Builder V10.1.2.0.2 - Production
    PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
    Oracle Query Builder 10.1.2.0.2 - Production
    Oracle Virtual Graphics System Version 10.1.2.0.2 (Production)
    Oracle Tools GUI Utilities Version 10.1.2.0.2 (Production)
    Oracle Multimedia Version 10.1.2.0.2 (Production)
    Oracle Tools Integration Version 10.1.2.0.2 (Production)
    Oracle Tools Common Area Version 10.1.2.0.2
    Oracle CORE     10.1.0.4.0     Production
    And:
    Report Builder 10.1.2.0.2
    ORACLE Server Release 10.1.0.4.2
    Oracle Procedure Builder 10.1.2.0.2
    Oracle ORACLE PL/SQL V10.1.0.4.2 - Production
    Oracle CORE     10.1.0.4.0     Production
    Oracle Tools Integration Services 10.1.2.0.2
    Oracle Tools Common Area 10.1.2.0.2
    Oracle Toolkit 2 for Windows 32-bit platforms 10.1.2.0.2
    Resource Object Store 10.1.2.0.2
    Oracle Help 10.1.2.0.2
    Oracle Sqlmgr 10.1.2.0.2
    Oracle Query Builder 10.1.2.0.2 - Production
    PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
    Oracle ZRC 10.1.2.0.2
    Oracle XML Developers Kit 10.1.0.4.2 - Production
    Oracle Virtual Graphics System 10.1.2.0.2
    Oracle Image 10.1.2.0.2
    Oracle Multimedia Widget 10.1.2.0.2
    Oracle Tools GUI Utilities 10.1.2.0.2
    Any advice will be welcome
    Thanx
    Rob

    This package currently compiles fine with the latest gcc (at least last time I checked), but still I'm having trouble making a package for it because I don't know how to get it to install to a custom location like the $startdir/pkg directory.

  • "catch is unreachable" compiler error with java try/catch statement

    I'm receiving a compiler error, "catch is unreachable", with the following code. I'm calling a method, SendMail(), which can throw two possible exceptions. I thought that the catch statements executed in order, and the first one that is caught will execute? Is their a change with J2SE 1.5 compiler? I don't want to use a generic Exception, because I want to handle the specific exceptions. Any suggestions how to fix? Thanks
    try {
    SendMail(....);
    } catch (MessagingException e1) {
    logger.fine(e1.toString());
    } catch (AddressException e2) {
    logger.fine(e2.toString());
    public String SendMail(....) throws AddressException,
    MessagingException {....                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I found the problem:
    "A catch block handles exceptions that match its exception type (parameter) and exception types that are subclasses of its exception type (parameter). Only the first catch block that handles a particular exception type will execute, so the most specific exception type should come first. You may get a catch is unreachable syntax error if your catch blocks do not follow this order."
    If I switch the order of the catch exceptions the compiler error goes away.
    thanks

  • Servlet with Database Access!!!

    Hi !!!!
    I have deployed HelloServlet with Oracle Application Server 4.0.8.1.
    Now I want to connect from Servlet to Oracle8i 8.1.5.
    But, when I try to deploy a Servlet with Database Access, I receive the next:
    "Get operation not allowed"
    The URL used is:
    http://host.domain:port/virtual_path/class_name
    The servlet was compiled using the Sun's jdk from command line. There wasn't compilation errors.
    I run a simple application with database access from command line without problems.
    The drivers and JDBC libraries are operating for this simple application.
    Any help will be appreciated.
    Many thanks
    Sergio

    If you are running OAS 4.0.8.1 and Oracle 8.1.5 on the same machine then this could be the problem. These products are not certified to run on the same machine as they give a path conflict.
    Hope this helps.

  • I can't compile servlets

    Please ignore my previous Thread.
    Where do you get the nessecary libaries to compile servlets, and what directory of the JSDK1.4.0/ directory do you put them in (Im using Win98se)

    File To Compile:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloClientServlet extends HttpServlet
         protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
         res.setContentType("text/html");
         PrintWriter out = res.getWriter();
              out.println("<HTML><HEAD><TITLE>Hello Client!</TITLE>"+
         "</HEAD><BODY>Hello Client!</BODY></HTML>");
              out.close();
         public String getServletInfo()
              return "HelloClientServlet 1.0 by Stefan Zeiger";
    Error Messages:
    C:\ServletDevelopment\HelloClientServlet.java:2: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    C:\ServletDevelopment\HelloClientServlet.java:3: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    C:\ServletDevelopment\HelloClientServlet.java:4: cannot resolve symbol
    symbol : class HttpServlet
    location: class HelloClientServlet
    public class HelloClientServlet extends HttpServlet
    ^
    C:\ServletDevelopment\HelloClientServlet.java:6: cannot resolve symbol
    symbol : class HttpServletRequest
    location: class HelloClientServlet
         protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    ^
    C:\ServletDevelopment\HelloClientServlet.java:6: cannot resolve symbol
    symbol : class HttpServletResponse
    location: class HelloClientServlet
         protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    ^
    C:\ServletDevelopment\HelloClientServlet.java:6: cannot resolve symbol
    symbol : class ServletException
    location: class HelloClientServlet
         protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    ^
    6 errors
    Tool completed with exit code 1

Maybe you are looking for

  • Error while executing the function

    hi, I have a table with the following data. T_1          T_2 T_3        T_4 a.1            1 aa         ff a.1            2 ab         ff a.2            1 ba         ff a.2            2 bb         ff a.2            3 bc         ff a.2            4 bd

  • My store account was blocked and i dont know why?

    dears, Good day am faceing a problem long time with my App. account, i cant login with my user its says"blocked"disable. please i need you support

  • FMCN - Open Item upload Commitment not updated in case of Service Entry

    Hi All, I am trying to use FMCN to update commitment and fund centers in open PO's and GR's, however where there is material PO's it updating perfectly but if there is Service PO then it is not updating in GR/IR account with non budgeted commitment I

  • Nomad Jukebox Zen Xtra PLEASE HE

    My player was locked on the EAX screen, and I figured out how to get to the rescue mode, and I clicked "Clean Up" and then pressed the check, and then it went back to the rescue mode screen and nothing's happening. Where do I go from here? What does

  • ODS and Transformations get inactive after i transport it in PD.

    i have transported my  ETL model in production , Now Everything what we have transported has come into production system but transformation and ODS in our ETL model get inactivated . Also while i want to display the transformation it give massege tha