• 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
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Unable to complie

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43024
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic