This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Compiling a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Compiling a servlet" Watch "Compiling a servlet" New topic

Compiling a servlet

wayne drummond

Joined: Jan 15, 2001
Posts: 9
I'm having a problem compiling the hello world sample servlet.
I getting an error whenever I try to compile the java file. For one reason or another I'm getting an error stating that the javax.servlet.*; package does not exist. I've tried compiling it in TextPad,the command line, and in JBuilder but no luck. Also I've tried running a servlet that came with Tomcat and it works just fine, so I tried to compile the java file and that also failed. Can anyone help or point me in the right direction. Thanks
Cynthia Yao
Ranch Hand

Joined: Nov 06, 2000
Posts: 92
Well, the first thing I can think of is classpath. When u use JBuilder, either add where tomcat servlet.jar in u project library. Or edit u autoexec.bat to include the jar file.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
when the compiler can't find a package, most times
it has to do with your classpath and not the editor.
having said that, whats' your classpath?
you should have added %TOMCAT_HOME%\lib\servlet.jar
to your classpath and then compile the servlet.
- satya

OOPS.....i din't know i was competing with you Cinthia....

[This message has been edited by Madhav Lakkapragada (edited February 01, 2001).]

Take a Minute, Donate an Hour, Change a Life
wayne drummond

Joined: Jan 15, 2001
Posts: 9
Thanks for the help I figured as much. I've been tinkering with my classpath and I'm not sure if it is correct, however here is a copy of what I have.
E:\Oracle\Ora81\orb\classes\yoj.jar;E:\Oracle\Ora81\orb\classes\;C:\jdk1.3\bin;C:\JAVA;C:\Java\;C:\jakarta-tomcat-3-2-1\lib\servlet.jar;C:\jakarta-tomca t-3-2-1\lib\jasper.jar;c:\java\;C:\jakarta-tomcat-3-2-1\lib;c:\jdk1.3\lib\tools.jar
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
E:\Oracle\Ora81\orb\classes\yoj.jar;E:\Oracle\Ora81\orb\classes\;C:\jdk1.3\bin;C:\JAVA;C:\Java\;C:\jakarta-tomcat-3-2-1\lib\servlet.jar;C:\jakarta-to mcat-3-2-1\lib\jasper.jar;c:\java\;C:\jakarta-tomcat-3-2-1\lib;c:\jdk1.3\lib\tools.jar
IMO, I would limit it to have the bare minimum....something like this:
Also make sure that tomcat_home is C:\jakarta-tomcat-3-2-1
Somehow, till know I have seen something like C:\jakarta-tomcat-3.2.1
Pl. check with your system.

- satya
I agree. Here's the link:
subject: Compiling a servlet
Similar Threads
Struts ActionForm: ClassCastException caused by FormTag.initFormBean
Jasper reports error in weblogic 8.1
The infamous "NoClassDefFoundError"
jsp interger values
HFSJ doubts