File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes unable to locate javax.servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "unable to locate javax.servlet" Watch "unable to locate javax.servlet" New topic

unable to locate javax.servlet

Monty Caywood

Joined: Mar 31, 2011
Posts: 2

I am trying to make a simple servlet. I've imported javax.servlet.* and compiler is complaining that it can't be found. I've researched this problem and everything points to my CLASSPATH. I’ve downloaded the j2ee.jar, I have pointed my CLASSPATH to C:\Sun\AppServer\lib (where the j2ee.jar file is) along with pointing it to C:\Tomcat 5.5\common\lib where the servlet-api.jar is located and I still get the same error message (and I have rebooted the system). Can anyone help please?!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63856

The only way that this will happen is if servlet-api.jar is not in the classpath. You say that you have added it correctly, but if it were, you would not be getting the message.

[Asking smart questions] [About Bear] [Books by Bear]
Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
You say you have pointed the classpath at the directories where the jar files are. That is not enough - you have to include the full path including the name of the jar file.

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46362
. . . and welcome to the Ranch
Monty Caywood

Joined: Mar 31, 2011
Posts: 2
Thank you all for the post! Actually Mr. Bibeault, my classpath was correct. I even added the .jar file directly in the classpath as Joanne suggested and it still wouldn't reconize the import statement. I had to go into NetBeans, go the Project tab, right clicking on the Libraries and adding the Jar file that way.
Again all thank you very much for your input!!!
jQuery in Action, 3rd edition
subject: unable to locate javax.servlet
It's not a secret anymore!