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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to compile Servlets" Watch "How to compile Servlets" New topic
Author

How to compile Servlets

Tina Ang
Ranch Hand

Joined: Mar 12, 2002
Posts: 58
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

Joined: Apr 22, 2000
Posts: 33
please put java.exe and javac.exe in correct path
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

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 ]

- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Tina Ang
Ranch Hand

Joined: Mar 12, 2002
Posts: 58
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

Joined: Oct 17, 2001
Posts: 4313

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

Joined: Mar 12, 2002
Posts: 58
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

Joined: Jan 11, 2002
Posts: 39
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

Joined: Mar 12, 2002
Posts: 58
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

Joined: Oct 21, 2000
Posts: 4340
    
    2

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


SCJP
Visit my download page
Tina Ang
Ranch Hand

Joined: Mar 12, 2002
Posts: 58
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
 
Don't get me started about those stupid light bulbs.
 
subject: How to compile Servlets