aspose file tools*
The moose likes Servlets and the fly likes Newbie question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Newbie question" Watch "Newbie question" New topic
Author

Newbie question

Harry Kong
Ranch Hand

Joined: Dec 06, 2002
Posts: 41
I am trying to complile a simple servlet program, and the complier complains that the packages do not exsit. These two:
import javax.servlet.*;
import javax.servlet.http.*;
I've setup the CLASSPATH as:
CLASSPATH=%CLASSPATH%;C:\Tomcat4.0.1\common\lib\servlet.jar
This is according to Manning's SCWCD Study Kit book. I also setup CATALINA_HOME, JAVA_HOME, and appropriate paths. Is there more to be done? What am I doing wrong?
Thanks, Harry.
PS - I am using Windows 2000.


SCJP 1.4
DC Dalton
Ranch Hand

Joined: May 28, 2001
Posts: 287
Make sure your path to the servlet.jar is correct, thats the only thing I can see that would be wrong.
Harry Kong
Ranch Hand

Joined: Dec 06, 2002
Posts: 41
Do you mean this line?
CLASSPATH=%CLASSPATH%;C:\Tomcat4.0.1\common\lib\servlet.jar
Or do you mean
PATH=C:\Tomcat4.0.1\common\lib\servlet.jar
Thanks.
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
It should be your classpath.


Matthew Phillips
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

when you compile, what does the command line look like?
Harry Kong
Ranch Hand

Joined: Dec 06, 2002
Posts: 41
I double checked and the classpath is okay.
I use regulat complie command to compile, that is:
javac Hello.java
Is there some other option I have to specifiy?
Dominic Paquette
Ranch Hand

Joined: Dec 13, 2002
Posts: 64
hi,
try
javac -classpath C:\Tomcat4.0.1\common\lib\servlet.jar hello.java
Dominic
Harry Kong
Ranch Hand

Joined: Dec 06, 2002
Posts: 41
Hmm, no that didn't work either. Arrrgh, this is very frustrating. This should be a simple task.
Rich Raposa
Ranch Hand

Joined: Dec 06, 2001
Posts: 46
This is a CLASSPATH problem. Your CLASSPATH is not set correctly. Search your computer for servlet.jar, because it's obviously not in:
C:\Tomcat4.0.1\common\lib\


Rich Raposa<br /><a href="http://www.javalicense.com" target="_blank" rel="nofollow">http://www.javalicense.com</a><br />Buy Java courseware -> get a free XBox!
Harry Kong
Ranch Hand

Joined: Dec 06, 2002
Posts: 41
Classpath is correct. That's where servlet.jar is.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

That should work.

If your class file is here:
c:\tomcat4.0.1\webapps\foo\foo.java

then the following command should compile the servlet:

c:\tomcat4.0.1\webapps\foo> javac -classpath .;c:\tomcat4.0.1\common\lib\servlet.jar foo.java

This assumes your servlet is not packaged.

If you type in the exact command as above (replacing 'foo' where appropriate) what is the exact error message you get back?

Also remember, java is case-sensitive, so "Foo" is different than "foo".
[ January 18, 2003: Message edited by: Mike Curwen ]
Harry Kong
Ranch Hand

Joined: Dec 06, 2002
Posts: 41
Mike, that worked! Thanks!!!
I am soooo happy!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Newbie question