• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cannot compile and run my servlet program

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
JulianInactive KennedyInactive
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all. i've solved the problems
 
JulianInactive KennedyInactive
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

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

Thanks

Jules
 
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic