Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Previously, I have set the JAVA_HOME path using the terminal with the following command:

export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-i386" >> ~/.bashrc

Now, I want to set the CLASSPATH environment variable to include the servlet-api.jar. Basically, what I am trying to achieve is that I should not need to type the classpath to servlet-api.jar every time I compile a Java program nor should I have to type -cp . when compiling a regular Java program whose .class file is in the same directory

I am a newbie from Windows so please a step-by-step guide would be appreciated!

share|improve this question
up vote 1 down vote accepted

The CLASSPATH variable can be extended in this way




But I think your question is not reflecting your right intention.

servlet-api.jar is an api. It is only needed at compile time.
On run time an implementation is provided by a container like tomcat.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.