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!


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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