Help With Javax.Servlet


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Help With Javax.Servlet

  1. #1
    dobject Guest

    Help With Javax.Servlet


    Hi,
    I tried to compile a java file ( downloded from the net), but I got the errors
    below. I downloded the servlet.jar from SUN Site, but still have the same
    problem.

    I'll appreciate any help.
    TIA,
    Dobject

    E:\mous\jsp\servlet>javac SearchEngines.java
    SearchEngines.java:4: Package javax.servlet not found in import.
    import javax.servlet.*;
    ^
    SearchEngines.java:5: Package javax.servlet.http not found in import.
    import javax.servlet.http.*;
    ^
    SearchEngines.java:21: Superclass coreservlets.HttpServlet of class coreservlets
    .SearchEngines not found.
    public class SearchEngines extends HttpServlet {
    ^
    3 errors

  2. #2
    Kyle Gabhart Guest

    Re: Help With Javax.Servlet


    "dobject" <dobject@caramail.com> wrote:
    >
    >Hi,
    >I tried to compile a java file ( downloded from the net), but I got the

    errors
    >below. I downloded the servlet.jar from SUN Site, but still have the same
    >problem.
    >
    >I'll appreciate any help.
    >TIA,
    >Dobject
    >
    >E:\mous\jsp\servlet>javac SearchEngines.java
    >SearchEngines.java:4: Package javax.servlet not found in import.
    >import javax.servlet.*;
    > ^
    >SearchEngines.java:5: Package javax.servlet.http not found in import.
    >import javax.servlet.http.*;
    > ^
    >SearchEngines.java:21: Superclass coreservlets.HttpServlet of class coreservlets
    >.SearchEngines not found.
    >public class SearchEngines extends HttpServlet {
    > ^
    >3 errors


    Hello,

    In addition to downloading the servlet.jar file, you need to include the
    jar file in your classpath so that java can see the class files contained
    inside it. You can do this one of two ways:

    1. Include the path to servlet.jar everytime you compile:

    javac -classpath c:\java\jars\servlet.jar SearchEngines.java

    2. Modify your system's classpath variable so that your system can see the
    jar file without you including it every time you compile a java source file.
    Changing your classpath will vary depending on the platform you are using.

    **On windows 95/98:

    -edit your autoexec.bat file located at c:\autoexec.bat

    -add the following line to the file (below any previous CLASSPATH statements:

    Set CLASSPATH=%CLASSPATH%;C:\PATH_TO_JAR_FILE\servlet.jar

    **On windows 2000:

    -Right click on "My Computer" and select "Properties".
    -Click the "Advanced" tab and then click the "Environment Variables" button.
    -Create a "New" variable

    Variable Name: Classpath
    Variable Value: %CLASSPATH%;C:\PATH_TO_JAR_FILE\servlet.jar

    **On Unix/Linux/Solaris:

    -edit/create your .bashrc file or .profile file located in your home directory.

    -Add the following lines to that file:

    CLASSPATH=%CLASSPATH%ath\to\jar_file\servlet.jar
    export CLASSPATH

    -Then run:

    source <filename>


    Now you should be ready to access your java class files.

    Let me know if you have any more trouble.

    Happy Coding!

    Kyle Gabhart
    DevX Java Pro


  3. #3
    Nilesh Gupta Guest

    Re: Help With Javax.Servlet


    Hi.
    You need to have Java Servlet Kit(jsdk) for the following errors.


    "dobject" <dobject@caramail.com> wrote:
    >
    >Hi,
    >I tried to compile a java file ( downloded from the net), but I got the

    errors
    >below. I downloded the servlet.jar from SUN Site, but still have the same
    >problem.
    >
    >I'll appreciate any help.
    >TIA,
    >Dobject
    >
    >E:\mous\jsp\servlet>javac SearchEngines.java
    >SearchEngines.java:4: Package javax.servlet not found in import.
    >import javax.servlet.*;
    > ^
    >SearchEngines.java:5: Package javax.servlet.http not found in import.
    >import javax.servlet.http.*;
    > ^
    >SearchEngines.java:21: Superclass coreservlets.HttpServlet of class coreservlets
    >.SearchEngines not found.
    >public class SearchEngines extends HttpServlet {
    > ^
    >3 errors



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