Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Compiling a Java Servlet

Posted on 2003-11-04
8
Medium Priority
?
405 Views
Last Modified: 2010-04-01
I have installed JSDK2.0 on machine to run the servlets. I have HelloWorld servlet in "C:\JSDK2.0\examples" directory. I am having problem compiling this servlet. I get the following error.

C:\JSDK2.0\examples>javac HelloServletWorld.java
HelloServletWorld.java:4: cannot resolve symbol
symbol : class HttpServlet
location: class HelloServletWorld
public class HelloServletWorld extends HttpServlet {
^
HelloServletWorld.java:6: cannot resolve symbol
symbol : class HttpServletRequest
location: class HelloServletWorld
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
HelloServletWorld.java:6: cannot resolve symbol
symbol : class HttpServletResponse
location: class HelloServletWorld
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
3 errors

I know there must error in setting the path and classpath variables. I set the path = "C:\jdk1.3.1_07\bin;C:\jsdk2.0\bin" and classpath ="C:\jsdk2.0\lib\jsdk.jar". Can anybody tell me what is wrong in the settings? Can help would be appreciated.

Thank you
0
Comment
Question by:Kiranmayee
7 Comments
 
LVL 15

Expert Comment

by:jimmack
ID: 9679358
You need to include the servlet.jar file in your classpath.

eg.  If it is in c:\jakarta-tomcat\commons\lib\servlet.jar

Use:

javac -g -classpath c:\jakarta-tomcat\commons\lib\servlet.jar HelloServletWorld.java

You might want to consider using the "-d" option too, to tell the compiler where to write the .class files
0
 

Author Comment

by:Kiranmayee
ID: 9679439
I am using JSDK server not tomcat server. I got it fixed. I set the path = "C:\jdk1.3.1_07\bin;C:\jsdk2.0\bin" and classpath ="C:\jsdk2.0\lib\jsdk.jar". I included the "import javax.servlet.http.*;" statement in my servlet. Thank you for your immediate response.

Thank you
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9679584
Sorry.  I mis-read that as j2sdk :-(

You need to include the .JAR file that contains the javax.servlet... classes.  I'm not sure what it's called in JSDK.  Have a look to see what is in the \lib directory.

You can use the following to see what is in a jar file:

jar tvf filename.jar
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:evedder
ID: 9683123
the jar you are looking for is servlet.jar as jimmack says but I dont remember either where is located
0
 

Author Comment

by:Kiranmayee
ID: 9683629
I downloaded JSDK from http://java.sun.com/products/servlet/archive.html. I don't have servlet.jar , i only see jsdk.jar in lib directory .  I included the "import javax.servlet.http.*;" statement in my servlet and it works. Thank you guys for your comments.
0
 

Expert Comment

by:paragagarwal
ID: 9712452
First set your servlet.jar in the classpath and then complie it.
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 10882470
PAQed, with points refunded (50)

CetusMOD
Community Support Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, the configuration steps in Zabbix to monitor devices via SNMP will be discussed with some real examples on Cisco Router/Switch, Catalyst Switch, NAS Synology device.
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question