Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7429665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:00:28+00:00 2026-05-29T09:00:28+00:00

I have a Servlet class in which I import javax.servlet.* and javax.servlet.http.* . When

  • 0

I have a Servlet class in which I import javax.servlet.* and javax.servlet.http.*.
When I try to compile it in command prompt I get the error

package javax.servlet does not exist

I use JDK 1.7.0 and Tomcat 6.0. I compile using javac. I am not using a build tool like Maven.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:00:29+00:00Added an answer on May 29, 2026 at 9:00 am

    You need to add the path to Tomcat’s /lib/servlet-api.jar file to the compile time classpath.

    javac -cp .;/path/to/Tomcat/lib/servlet-api.jar com/example/MyServletClass.java
    

    The classpath is where Java needs to look for imported dependencies. It will otherwise default to the current folder which is included as . in the above example. The ; is the path separator for Windows; if you’re using an Unix based OS, then you need to use : instead.

    If you’re still facing the same complation error, and you’re actually using Tomcat 10 or newer, then you should be migrating the imports in your source code from javax.* to jakarta.*.

    import jakarta.servlet.*;
    import jakarta.servlet.http.*;
    

    In case you want to keep using javax.* for whatever reason, then you should be downgrading to Tomcat 9 or older as that was the latest version still using the old javax.* namespace.

    See also:

    • jakarta.servlet.ServletException: Class [com.practice.MyServlet] is not a Servlet
    • How do I import the javax.servlet / jakarta.servlet API in my Eclipse project?
    • What exactly is Java EE?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a servlet class which handles login. At the end of my login
I have created a class which extends HttpServlet in a package called controller I
I have index.jsp from which I get the parameters to servlet LoginServlet.java The servlet
I'm working on an application. I have a servlet (writeDataBase.class) that writes some information
I have a servlet S which handles callbacks from a 3rd party site. The
We have a servlet which occupies more virtual memory on the server due to
We have a servlet which occupies more virtual memory on the server as it
I have a servlet which takes us to an existing jsp, say home.jsp. This
I have implemented the two classes shown at http://tomcat.apache.org/tomcat-6.0-doc/aio.html which gives a messenger application
I have this managed bean which takes two values from database's table import java.io.Serializable;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.