• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in compiling Servlet class

 
Monica Kapoor
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The value for the '-d' flag should be the directory that you want the compiled class file to go not the sorce file.
 
Monica Kapoor
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65128
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Monica Kapoor
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a ton.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic