This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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: 61063

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] [Bear's FrontMan] [About Bear] [Books by Bear]
Joanne Neal

Joined: Aug 05, 2005
Posts: 3455
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: 38405
. . . 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!!!
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: unable to locate javax.servlet