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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:00:08+00:00 2026-05-12T19:00:08+00:00

I know this is a common error, but bear with me. I’ve pursued the

  • 0

I know this is a common error, but bear with me. I’ve pursued the CLASSPATH problem and I don’t think that is the issue. I’m getting an error like this.

./src/process.java:2: package javax.servlet does not exist
import javax.servlet.*;

I installed Tomcat and the Java SDK, and I know that Tomcat is supposed to supply the servlet API. But what file is it exactly looking for?

I have the following settings:
JAVA_HOME=/usr/java/jdk1.6.0_16
CLASSPATH=/usr/share/java;/usr/share/java/tomcat6

The base directory for tomcat: /usr/share/tomcat6
In this directory, /usr/share/tomcat6/lib is simply a symlink to /usr/share/java/tomcat6

tomcat6-servlet-2.5-api-6.0.18.jar is in /usr/share/java/tomcat6, is there anything else I need to be telling javac about so it will use this library? Is there another library that I need?

For background, I’m trying to get a hello world servlet running. The code is as follows:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class process extends HttpServlet {

public void doGet( HttpServletRequest request, 
                   HttpServletResponse response)
              throws ServletException, IOException {

    PrintWriter out = response.getWriter();
    out.println("Hello World");

}
}

When I compile this with javac I get the following errors (amongst others of which this is the root cause):

./src/process.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
./src/process.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^

I tried specifying the classpath on the command line as well with the -cp option, but I ended up with the same results.

  • 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-12T19:00:09+00:00Added an answer on May 12, 2026 at 7:00 pm

    You need to set your classpath to point specifically to your JAR:

    CLASSPATH=/usr/share/java/tomcat/tomcat6-servlet-2.5-api-6.0.18.jar
    

    When you specify a folder in classpath, it’s only used to locate all classes within that folder. JARs by themselves are libraries (packaged folders, if you will) of classes and thus have to be listed individually. So, for example, you could do something like:

    CLASSPATH=/some/location/myjar1.jar:/other/location/myjar2.jar:/some/classes/folder
    

    in which case all classes from myjar1.jar, myjar2,jar and /some/classes/folder directory will be available to you. If you had myjar3.jar in /some/classes/folder, the above declaration would NOT add it to classpath.

    Update As McDowell pointed out, Java 6 allows wildcards in classpath that would pick up all jars in the specified folder. Wildcards work for JARs only, classes are not picked up unless the folder is specified again with no wildcard. Wildcards are also not recursive. So:

    CLASSPATH=/loc1/*:/loc1:/loc2/*
    

    would make all jars and all classes within /loc1 folder and all jars (but not classes) within /loc2 folder available. Deeper nested jars (/loc1/nested/some.jar) would not be picked up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know what happen about this error,this program i can run normaly early,
How can I do something like this but avoid the error column common_reference is
I've written an application that converts 1000s of Excel documents into PDFs (I know
Does anyone know how to find a list of all the possible error codes
I am parsing through a XML file that's about 12mb big. I need to
I already asked similar question here, but I still get some errors, so I
I hope my question is describing itself =) I tried to do everything but
This seems like it should be easy yet I must be missing something. I
I want to create custom error code and message mapping file. Currently I use
I am having big problems in fetching exception details from Remote EJBs... I have

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.