• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

javax.servlet not found

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ranchers i am very new to servlets. I have jdk1.5 installed in my pc
along with Sun Studio EnterpriseEdition
Whenever i try to compile my code (having import javax.servlet.*) from command prompt, it gives a compiler error of above package not found. Whereas my normal corejava codes compiles fine.Kindly tell me how to get the package in the path
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you need to install tomcat5.0 and j2ee 1.5 sdk as well. then set the eviroment variables as follows; (note that this is relative to where i have installed the relevant applications)

ANT_HOME - C:\Sun\AppServer\lib\ant
CLASSPATH - .;C:\apache-tomcat-5.5.17\apache-tomcat-5.5.17\common\lib\servlet-api.jar;C:\apache-tomcat-5.5.17\apache-tomcat-5.5.17\common\lib\jsp-api.jar;

J2EE_HOME - C:\Sun(where you install the j2ee sdk)
JAVA_HOME - C:\Sun\AppServer\jdk(where you have installed the j2se jdk)
PATH - "C:\Sun\AppServer\bin";"C:\Sun\AppServer\jdk\bin";"C:\Sun\AppServer\lib\ant\bin";%PATH%
thats about it... after that just compile your code from the command promt and check... hope this helped.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think the edition you are using doesn't contain classes which are necessary for servlets.

download jsdk2.1 and set

On windows system :

classpath to rootdirectory:\jsdk2.1\servlet.jar;rootdirectory:\jsdk2.1\server.jar

Example : classpath is D:\jsdk2.1\servlet.jar;D:\jsdk2.1\server.jar;
classpath is an user defined environment variable.
if it is not present then create it.

now after setting this compile your servlet.i think it must work.

i think i answered your question properly and this is the first reply for a question in this community.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Abhinav Pandey:
Hello ranchers i am very new to servlets. I have jdk1.5 installed in my pc
along with Sun Studio EnterpriseEdition
Whenever i try to compile my code (having import javax.servlet.*) from command prompt, it gives a compiler error of above package not found. Whereas my normal corejava codes compiles fine.Kindly tell me how to get the package in the path



All you need is your servlet library on your classpath. Typically servlet.jar or servlet-api.jar.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by bhagavatula indu sekhar:
download jsdk2.1



??

Moreover, SDK doesn't, typically, include servlet library.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adeel Ansari:
Moreover, SDK doesn't, typically, include servlet library.



JSDK -as opposed to the any of the Java SE/EE SDKs- used to be short for "Java Servlet Dev Kit", and it did include the jar files. But the term JSDK was dropped a while ago. The servlet jars are now available here, or as part of a Tomcat installation.
[ November 08, 2006: Message edited by: Ulf Dittmer ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See:
http://faq.javaranch.com/view?CompilingServlets

Moving to Java In General where javac and classpath issues are discussed.
 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to add [Java EE directory]\lib\javaee.jar to your classpath variable.

If you are still using J2EE instead of Java EE 5, you need to add [J2EE directory]\lib\j2ee.jar to your classpath.
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic