Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to locate javax.servlet

 
Monty Caywood
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch
 
Monty Caywood
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic