Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

import javax.GenericServlets not found

 
tushar attar
Ranch Hand
Posts: 38
Chrome Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , I am using tomcat and have setup the classpath in PATH enviroment variable to the servlet-api.jar file. Whenever i compile my java servlet code i get import javax.GenericServlets not found . Though if I compile code using -classpath "path to servlet api" while compiling code it compiles successfully.

What i am doing wrong while setting up the PATH variable?
 
Tim Moores
Saloon Keeper
Posts: 3325
61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) PATH has nothing to do with the classpath. CLASSPATH does, though, although I don't recommend using it.

2) javax.GenericServlets is not a class, nor does the "javax" package actually have any classes in it. Or was that just a copy/paste error?
 
tushar attar
Ranch Hand
Posts: 38
Chrome Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2) javax.GenericServlets is not a class, nor does the "javax" package actually have any classes in it. Or was that just a copy/paste error?

I am sorry that was typo error
import line is aactually import javax.servlet.*


PATH has nothing to do with the classpath. CLASSPATH does, though, although I don't recommend using it.

Then what is the solution?
 
Tim Moores
Saloon Keeper
Posts: 3325
61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If compiling using - classpath works, I don't think anything needs to be done.

Since the number of external libraries in your projects is likely to increase over time (which makes typing in command line arguments tiresome), you may want to look into build tools like Ant, Maven and Gradle.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!