File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Error in compiling Servlet class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error in compiling Servlet class" Watch "Error in compiling Servlet class" New topic
Author

Error in compiling Servlet class

Monica Kapoor
Greenhorn

Joined: Nov 08, 2005
Posts: 7
HI I am new to servlets and am reffering Head first for them.In chapter 3 on MVC it creates a servlet.I have kept the servlet java file (named BeerSelect.java) in the following path:

MyProjects/beer1/src/com/example/web/BeerSelect.java

this is the only palse i have kept it.

Now the author asks to compile servlet with the -d flag to put the class in the development enviornment.Using the following the command.

%cd MyProjects/beerV1
%javac -classpath c:/Tomcat 5.5/common/lib/servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java

and it gives me an error

javac: invalid flag: 5.5/common/lib/servlet-api.jar:classes:. -d

please help.

[ January 12, 2006: Message edited by: Bear Bibeault ]
[ January 12, 2006: Message edited by: Bear Bibeault ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The value for the '-d' flag should be the directory that you want the compiled class file to go not the sorce file.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Monica Kapoor
Greenhorn

Joined: Nov 08, 2005
Posts: 7
Thanks Ben for your reply can you please give me an example of it.Did you mean th replace the value of '-d' flag with the destination path.Sorry for not able your answer.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61202
    
  66

This isn't a servlets question -- it's about how to use java command line, so I'm shuffling this off to the Java in General (beginner) forum with an appropriate enhancement to the topic title.

I believe that you need to quote the classpath parameter so that the command line parser doesn't choke on the punctuation.
[ January 12, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
The problem is that the path that you want to specify with the -classpath flag has a space in it. The command-line parser thinks this space starts a new command-line argument. To fix this, you should put double-quotes around the path in order to tell the command-line parser that the space is part of the path.

Layne


Java API Documentation
The Java Tutorial
Monica Kapoor
Greenhorn

Joined: Nov 08, 2005
Posts: 7
Thanks a ton.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in compiling Servlet class