Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package javax.servlet does not exist

 
Gaurang Rathod
Greenhorn
Posts: 22
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 48968
60
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 22
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic