This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes package javax.servlet does not exist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package javax.servlet does not exist" Watch "package javax.servlet does not exist" New topic

package javax.servlet does not exist

Gaurang Rathod

Joined: Oct 30, 2012
Posts: 22

I use Tomcat, and notepad in Windows 7.

Cannot compile servlet.

If i set classpath on command line in cmd, it works.

But i cant set environment variable properly.

Please tell me if i set my variables correct:

CLASSPATH: %CLASSPATH%;.;C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar

JAVA_HOME: C:\Program Files\Java\jdk1.6.0

PATH: %JAVA_HOME%\jre\bin

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 45350
They both look incorrect. But only you can tell because only you know where things are installed on your computer. Test it like this, at the command line:You have picked up the JDK correctly if the versions shown are correct.
Unless that is a local classpath, it is a mistake to set it at all, and you should not have set a system classpath. You should always set your classpath locally to your application, because you will need a different classpath for each app.
That path looks incorrect. Your JAVA_HOME variable should not end 1.6.0 but 1.6.0_22 or similar, if you installed Java in the usual location. Also the PATH should point to …\jdk\bin nor jre. The jre folder does not contain the javac tool.
Also you should maybe end your PATH variable with ;%PATH% to pick up all the other folders in your path.

We have an FAQ about first programs, which has a section about setting the path.
Gaurang Rathod

Joined: Oct 30, 2012
Posts: 22

Thanks Campbell.

My PATH variable was set wrong. I set it to %JAVA_HOME%\\bin and now it works.

And my JAVA_HOME and CLASSPATH variables are correct.
I agree. Here's the link:
subject: package javax.servlet does not exist
It's not a secret anymore!