This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to compile Servlets

 
Tina Ang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! I can't compile my first servlet. I've already set my classpath and it point to servlet.jar and jasper.jar. When I try to compile my servlet using javac HelloWorld.java , the error is "Bad command or file name". I can't understand why this is the case. Hope you could help me.
Thank you,
Tina Ang
 
sean zang
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please put java.exe and javac.exe in correct path
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in other words... if you're in Windows, you need to set you PATH variable
set PATH=%PATH%;c:\jdk1.3.1\bin
(or whatever directory you've installed the JDK to)
[ June 06, 2002: Message edited by: Jessica Sant ]
 
Tina Ang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I already did that. I've also included c:\jdk1.3.1\bin in th autoexec file. When I compiled the servlet using javac HelloWorld.java , it does not recognize the classes from the javax.servlet and javax.servlet.http packages. Need your help...Thanks..
Tina Ang
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you provide the EXACT command you're typing. the EXACT error message, as well as your %CLASSPATH% and %PATH% environment variables. (You can display their values by typing set PA and set CL from the command prompt)??
That will help us be able to determine the cause of the problem you're having.
 
Tina Ang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here it is.
autoexec file:
PATH=%PATH%;.;C:\jakarta-tomcat-3.3.1\jakarta-tomcat-3.3.1\lib\common\servlet.jar;C:\jakarta-tomcat-3.3.1\jakarta-tomcat-3.3.1\lib\container\jasper.jar;C:\jdk1.3.1\bin;
In command prompt:
c:\jakarta-tomcat-3.3.1\jakarta-tomcat-3.3.1\webapps\root\web-inf\classes\javac HelloWorld.java
6 Errors one of which is:
HelloWorld.java7: cannot resolve symbol
symbol: class HttpServletRequest
location: class HelloWorld
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

Thank you!
Tina
 
tom mcmorrow
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi tina
i feel you may be confusing CLASSPATH with PATH.
servlet.jar needs to be placed in the CLASSPATH so the compiler can locate the classes therin rather than the PATH where executables are placed.
try on command line as follows-
set CLASSPATH=%CLASSPATH%;C:\jakarta-tomcat-3.3.1\jakarta-tomcat-3.3.1\lib\commom\servlet.jar;
and then try compiling as you have.
hope this helps.
tom
 
Tina Ang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks tom! Here's what I did:
set CLASSPATH=%CLASSPATH%;C:\jakarta-tomcat-3.3.1\jakarta-tomcat-3.3.1\lib\commom\servlet.jar;
path = c:\jdk1.3.1\bin\
c:\jakarta-tomcat-3.3.1\jakarta-tomcat-3.3.1\webapps\root\web-inf\classes\javac HelloWorld.java
GOT THE SAME 6 ERRORS!!! HELP!!!
 
Randall Twede
Ranch Hand
Posts: 4442
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i had so much trouble with this myself that i downloaded Forte (a free IDE for Jave). i dont use it much for creating but i use it to compile. it takes care of all the Classpath stuff for you
 
Tina Ang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's weird that the above procedure didn't work. Anyway a friend of mine told me to copy servlet.jar in C:\jdk1.3.1\jre\lib\ext and it worked...
Thank you!!!
Tina Ang
SCJP2
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic