This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes problem in compiling servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problem in compiling servlet" Watch "problem in compiling servlet" New topic
Author

problem in compiling servlet

Brij Garg
Ranch Hand

Joined: Apr 29, 2008
Posts: 234
I have java installed in system directory that is C:\j2sdk1.4.2_05\

tomcat is also in C:\Tomcat 5.0

I am not able to compile servlet test1.java from command prompt.

command and the message i am getting is given below.


C:\j2sdk1.4.2_05\bin>javac -classpath C:/Tomcat 5.0/common/lib/servlet-api.jar test1.java
javac: invalid flag: 5.0/common/lib/servlet-api.jar
Usage: javac <options> <source files>

can someone help ?
thanks
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

You can't have a space, try adding quotes:

javac -classpath "C:/Tomcat 5.0/common/lib/servlet-api.jar" test1.java
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Have you read our Servlets Faq? And this Compiling Servlets FAQ?
benjamin muktesh
Greenhorn

Joined: Jul 01, 2008
Posts: 24
Apart from what is already suggested, I would strongly recommend setting up the classpath and path variables. That way you wont have to provide the full path to your java file everytime you want to compile.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Originally posted by benjamin muktesh:
Apart from what is already suggested, I would strongly recommend setting up the classpath and path variables. That way you wont have to provide the full path to your java file everytime you want to compile.
Not usually a good idea to set a classpath permanently. The original poster's path must already be set, otherwise we would be looking at a load of different error messages.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in compiling servlet