aspose file tools*
The moose likes Servlets and the fly likes cannot compile and run my servlet program 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 "cannot compile and run my servlet program" Watch "cannot compile and run my servlet program" New topic
Author

cannot compile and run my servlet program

David Nelson
Greenhorn

Joined: Nov 13, 2003
Posts: 22
I've installed J2SE 1.4, J2EE 1.3 and tomcat 5.0, i think i configure them right, cause examples run very well. but when i write my own code, i cannot compile it at all, the problem is it cannot distinguish all related symbols. prompt msg like: package javax.servlet does not exist, cannot resolve symbol class HttpServlet.

Another question is how can i run my own servlet program, i generated one from JBuilder, and copied the class file to <tomcat-home>\webapps\servlets-examples\WEB-INF\classes, but the server canot find it(resource not available).

There are some hosts support JSP and servlet, how can i deploy my program on this kind of host. what should i pay more attention when i developing.

Cheers.
David Nelson
Greenhorn

Joined: Nov 13, 2003
Posts: 22
i list my configured parameters here:

JAVA_HOME=D:\JBuilderX\jdk1.4
J2EE_HOME=D:\Sun\j2sdkee1.3.1

PATH=%JAVA_HOME%\bin;
CLASSPATH=.;%J2EE_HOME%\lib\j2ee.jar

when i compile a java file, it says: package javax.servlet does not exist. connot resolve symbol HttpServlet, ...

i can run petstore demo on my local j2ee server, once start j2ee server, i can invoke this program through http://localhost:8000/petstore/index.jsp, however, i copy the petstore.war file to <tom-cat>\webapps\, and then start tomcat, the petstore.war package is uncompressed, but i cannot invoke it through http://localhost:8080/petstore/index.jsp

uncompressed directory:
petstore
|
|--index.jsp, all jsp files are presented here.
|--META-INF
|--images
|--WEB-INF

is there anything wrong with my operations? how can i compile my servlet code and deploy it on tomcat

any help and suggestions are appreciated.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
"package javax.servlet does not exist. connot resolve symbol HttpServlet"
Means the compiler can't find Tomcat 5's servlet-api.jar - it lives in CATALINA_HOME\common\lib
Bill
David Nelson
Greenhorn

Joined: Nov 13, 2003
Posts: 22
Hi, Bill, Thanks for your reply, but the problem still exists. :-(

Path=%JAVA_HOME%\bin;%ANT_HOME%\bin
JAVA_HOME=D:\JBuilderX\jdk1.4
J2EE_HOME=D:\Sun\j2sdkee1.3.1

CLASSPATH=%J2EE_HOME%\lib\j2ee.jar;D:\Program Files\tomcat5.0.27\common\lib\servlet-api.jar
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
David,

Are you doing all this through JBuilder or on the command line? Have you tried just creating a HelloWorld servlet and compiling that?

Note that Tomcat doesn't pay any attention to the CLASSPATH environment variable when running web apps.

Jules
David Nelson
Greenhorn

Joined: Nov 13, 2003
Posts: 22
Hi, Jules

i set this in the environment variables of WinXp, and i cannot compile a HelloWorld servlet at all, although i can run servlet with tomcat. Have no idea why is that

Regards
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
So you set the CLASSPATH through Control Panel in XP, but how are you compiling? The XP environment CLASSPATH is only useful if you're compiling from the command line, not from JBuilder.

If you're compiling from the command line can you please list the steps you go through, state what is says when you run "echo %classpath%" and the exact error message you get in full when you try to compile.

[Edit: You could also try specifying the classpath on the command line, e.g.:

Note the .; at the beginning, though I don't think it's significant in this case.

If you're compiling using JBuilder, look up how to set the CLASSPATH in the JBuilder help.

Jules
[ September 05, 2004: Message edited by: Julian Kennedy ]
David Nelson
Greenhorn

Joined: Nov 13, 2003
Posts: 22
Thanks all. i've solved the problems
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Hi David,

Can you please post your solution so that others may benefit?

Thanks

Jules
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot compile and run my servlet program