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 3333782
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:50:03+00:00 2026-05-17T23:50:03+00:00

I want to develop with Servlets in Eclipse, but it says that the package

  • 0

I want to develop with Servlets in Eclipse, but it says that the package javax.servlet / jakarta.servlet cannot be resolved. How can I add javax.servlet / jakarta.servlet package to my Eclipse project?

  • 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-17T23:50:03+00:00Added an answer on May 17, 2026 at 11:50 pm

    Ensure you’ve the right Eclipse and Server version

    Ensure that you’re using at least Eclipse IDE for Enterprise Java (and Web) developers (with the Enterprise). It contains development tools to create dynamic web projects and easily integrate servletcontainers (those tools are part of Web Tools Platform, WTP). In case you already had Eclipse IDE for Java (without Enterprise), and manually installed some related plugins, then chances are that it wasn’t done properly. You’d best trash it and grab the real Eclipse IDE for Enterprise Java one.

    You also need to ensure that you already have a servletcontainer installed on your machine which implements at least the same Servlet API version as the servletcontainer in the production environment, for example Apache Tomcat, RedHat WildFly, Eclipse GlassFish, etc. Usually, just downloading the ZIP file and extracting it is sufficient. In case of Tomcat, do not download the EXE format, that’s only for Windows based production environments. See also a.o. Several ports (8005, 8080, 8009) required by Tomcat Server at localhost are already in use.

    A servletcontainer is a concrete implementation of the Servlet API. Also note that for example WildFly and GlassFish are more than just a servletcontainer, they also support JSF (Faces), EJB (Enterprise Beans), JPA (Persistence) and all other Jakarta EE fanciness. See also a.o. What exactly is Java EE?

    Ensure that you’re using the right Servlet package

    The javax.* package has been renamed to jakarta.* package since Servlet API version 5.0 which is part of Jakarta EE 9 (Tomcat 10, TomEE 9, WildFly 22 Preview, GlassFish 6, Payara 6, Liberty 22, etc). So if you’re targeting these server versions or newer, then you need to replace

    import javax.servlet.*;
    import javax.servlet.http.*;
    

    by

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

    in order to get it to compile, else you might risk to face this build error

    The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

    Integrate Server in Eclipse and associate it with Project

    Once having installed both Eclipse for Enterprise Java and a servletcontainer on your machine, do the following steps in Eclipse:

    1. Integrate servletcontainer in Eclipse

      a. Via Servers view

      • Open the Servers view in the bottom box.

      • Rightclick there and choose New > Server.

      • Pick the appropriate servletcontainer make and version and walk through the wizard.

        enter image description here

      b. Or, via Eclipse preferences

      • Open Window > Preferences > Server > Runtime Environments.

      • You can Add, Edit and Remove servers here.

        enter image description here

    2. Associate server with project

      a. In new project

      • Open the Project Navigator/Explorer on the left hand side.

      • Rightclick there and choose New > Project and then in menu Web > Dynamic Web Project.

      • In the wizard, set the Target Runtime to the integrated server.

        enter image description here

      b. Or, in existing project

      • Rightclick project and choose Properties.

      • In Targeted Runtimes section, select the integrated server.

        enter image description here

      Either way, Eclipse will then automatically take the servletcontainer’s libraries in the build path. This way you’ll be able to import and use the Servlet API.

    Never carry around loose server-specific JAR files

    You should in any case not have the need to fiddle around in the Build Path property of the project. You should above all never manually copy/download/move/include the individual servletcontainer-specific libraries like servlet-api.jar, jsp-api.jar, el-api.jar, j2ee.jar, javaee.jar, etc. It would only lead to future portability, compatibility, classpath and maintainability troubles, because your webapp would not work when it’s deployed to a servletcontainer of a different make/version than where those libraries are originally obtained from.

    In case you’re using Maven, you need to make absolutely sure that servletcontainer-specific libraries which are already provided by the target runtime are marked as <scope>provided</scope>. You can find examples of proper pom.xml dependency declarations for Tomcat 10+, Tomcat 9-, JEE 9+ and JEE 8- in this answer: How to properly configure Jakarta EE libraries in Maven pom.xml for Tomcat?

    Here are some typical exceptions which you can get when you litter the /WEB-INF/lib or even /JRE/lib, /JRE/lib/ext, etc with servletcontainer-specific libraries in a careless attempt to fix the compilation errors:

    • java.lang.NullPointerException at org.apache.jsp.index_jsp._jspInit
    • java.lang.NoClassDefFoundError: javax/el/ELResolver
    • java.lang.NoSuchFieldError: IS_DIR
    • java.lang.NoSuchMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;
    • java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
    • org.apache.jasper.JasperException: The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
    • java.lang.VerifyError: (class: org/apache/jasper/runtime/JspApplicationContextImpl, method: createELResolver signature: ()Ljavax/el/ELResolver;) Incompatible argument to function
    • jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.