This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Servlets and the fly likes Please Basic Doubt! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Please Basic Doubt!" Watch "Please Basic Doubt!" New topic

Please Basic Doubt!

ramakrishna pydipati

Joined: Oct 13, 2003
Posts: 23
hai everybody,
I am new to java servlets .
I have java in c:/jdk1.4.1_02
my class path variables are:
now I downloaded jswdk-1.0.1 for servlets
it was in C:\jsdksevlet\jswdk-1.0.1
I started tomcat server
when I tried to compile on the server it is giving error
so how to fix it?
I included in CLASSPATH:C:\jsdksevlet\jswdk-1.0.1\lib
[ October 13, 2003: Message edited by: Mike Curwen ]
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
this might not solve all your problems but JAVA_HOME should point to your java directory NOT the java/bin directory. PATH should point to the bin directory. CLASSPATH should include the java/lib directory. also tomcat needs CATALINA_HOME to point to where you installed tomcat. im not sure what all that jswdk-1.0.1 is you have and im not sure if you need it, ill let someone else deal with that.

Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I'm not sure how people bypass much newer downloads like this. Or why Sun doesn't put up a huge "STOP" animated gif or something, on those pages.

jswdk-1.0.1 was released in 1999.

Un-install that package and get:
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I've just read your post closer. It seems you have tomcat already? Then just uninstall that JSWDK and removing all traces of it from classpath, path, java_home, etc, etc.

Everything you need to compile and run servlets is included with the Tomcat download.

as Tim mentioned,
JAVA_HOME should be c:\jdk1.4.1_02
CATALINA_HOME should be c:\tomcat4.1.27 (or similar)

You can ignore CLASSPATH, as Tomcat does NOT use system classpath.

But to compile your servlets, you'll need to ensure that servlet.jar is on the classpath. I'd recommend getting cozy with ANT, or use the command-line -classpath switch over system CLASSPATH. servlet.jar is included with the Tomcat distribution.
ramakrishna pydipati

Joined: Oct 13, 2003
Posts: 23
I really appreciate your help.Thanks you very much.
one more thing, just now I am reading a book, it says JSDK files has to be in my classpath ,to run servlet, so what I have to do?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

First it was jswdk, now it's jsdk. Which one? The reason I'm being particular is that almost any combination of letters that starts with 'j' has at one time been provided as a download/api/package by Sun.

JSWDK: JavaServer Web Development Kit
JSDK : Java Servlet Development Kit
*Neither* of which is the latest. And I'm not talking just a few months or even a year. You'd have to find these downloads in the archive section of Sun's web site.

What you *need* to do is stop reading that book. If it talks about the newest technology, but makes mistakes like referring to it as a jsdk, then it's not a good book. If it's not making a mistake, then the book is *very* out of date.

If it's the only book you got, then we'll try to make the best of it.

As for classpath... please do NOT concern yourself with classpath if you are using Tomcat. Tomcat does NOT use the system CLASSPATH variable. Simply installing Tomcat and setting CATALINA_HOME variable is all you need. This is explained in the Tomcat installation documents.

The only time you worry about classpath is when you are *compiling* servlets. And this is more appropriately handled by sending the path to servlet.jar (the jar file that contains all the servlet API classes) as a command-line switch to javac.

Something like:

javac -classpath .;%CATALINA_HOME%/common/lib/servlet.jar
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
Another suggestion ... If you don't want to spend the time learning Ant(recommended) and you don't want to have to keep typing out this long command line just to compile servlet(s) i.e. and believe me, you will be doing this alot. I would recommend creating and storing this information in a CLASSPATH environment variable for example
This particular line of code uses the j2ee.jar file from the enterprise edition which includes the servlet api and among others. Which you can also download form Sun's website.
Or you can just use the servlet.jar file from tomcat, for example

Also one more thing don't forget the period, it says include your PWD(present working directory) as apart of your classpath.
Now all you have to do at the command line is

But choose the way that is more efficient for you.

ramakrishna pydipati

Joined: Oct 13, 2003
Posts: 23
thank you very much . I really appreciate u r help.
I agree. Here's the link:
subject: Please Basic Doubt!
It's not a secret anymore!