File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Unable to complie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Unable to complie" Watch "Unable to complie" New topic
Author

Unable to complie

hemant chaudhary
Greenhorn

Joined: Feb 22, 2007
Posts: 20
I am new to Servlets and JSPs.I am reading HF Servlets and JSP book so I have written my first servlet as code is given in HF on page no 30 and 31 and I have followed all steps(folder making etc).

I have made my project folder in F drive path is : F:\project1

my tomcat folder path is C:\Program Files\Apache Software Foundation\Tomcat 4.1

Now in book it is written that I need to use this command

%javac -classpath /your path/tomcat/common/lib/servlet-api.jar -d classes src/Ch1Servlet.java

So I m using

javac -classpath C:/Program Files/Apache Software Foundation/Tomcat 4.1/common/lib/servlet-api.jar -d classes src/Ch1Servlet.java

It is saying:

javac: invalid flag: Files/Apache
Usage: javac <options> <source files>
use -help for a list of possible options

but on my comp i can compile any java file.
one more thing I don't have this file(servlet-api.jar) in my lib folder of tomcat.

Please suggest a solution.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
If the classpath contains spaces it needs to be surrounded by quotes:


That servlet-api.jar is not in common/lib sounds like a problem - which libraries do you have in that directory?
[ May 27, 2007: Message edited by: Ulf Dittmer ]

Ping & DNS - updated with new look and Ping home screen widget
Pravin Jain
Ranch Hand

Joined: May 20, 2007
Posts: 60
The problem is with the spaces in the path mentioned with the classpath switch.
pl. set CLASSPATH variable by using "<path>"
ex. -classpath "C:/Program Files/Apache Software Foundation/Tomcat 4.1/common/lib/servlet-api.jar"

This is the problem with your command line.


The Zen of Java Programming.
rahul khanna
Ranch Hand

Joined: Sep 14, 2005
Posts: 48
Spaces indeed are a problem.
Servet-api.jar should have been present by default.
What happened to that were you able to fix it ?

-Cheers
hemant chaudhary
Greenhorn

Joined: Feb 22, 2007
Posts: 20
sorry for late reply.

after including quotes i was getting 5 errors:

One of them:
-------------------------------------------------------------------
F:\project1>javac -classpath "C:/Program Files/Apache Software Foundation/Tomcat
4.1/common/lib/servlet-api.jar" -d classes src/Ch1Servlet.java
src\Ch1Servlet.java:1: package javax.servlet does not exist
import javax.servlet.*;
^

-----------------------------------------------------------------------

Then I changed sevlet-api.jar to servlet.jar(this one is ther ein lib directory) and now it is working

Thanks to all you people for replying.

~Hemant
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to complie
 
Similar Threads
Basic doubt in compiling servlets
How to compile java file in Tomcat ?
Cannot get Servlets Demystified Problem
Error while compling
classpath help with examples