Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About the book, Head First Jsp and Servlets, second edition's first problem.

 
Carlos L Sanchez
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am new to this forum and just learned of its existence because the author encourages the reader to seek help here
I must confess that I love to study on my own, but i have certainly have hit a wall with this first problem.
These examples seem to be explaining things in a very rudimentary way...
I don’t think this should be even this hard, the fact that I am coding outside a compiler augments the difficulty of this problem.
I wonder why the author did not opt for just building
a project in eclipse or NetBeans and saved the new users all of the trouble?
Anyways here is my question
I made it to page 81, where one has to "compile the servlet" the author instructs to introduce this line of code into the cmd:
javac -classpath /users/bert/Applications2/tomcat/common/lib/
servlet-api.jar:classes. -d classes src/com/example/web/BeerSelect.java

He then instructs you to adapt this to your actual path which in my case is:
javac -cp C:\Users\Carlos L\Tomcat\apache-tomcat-8.0.28\lib\servlet-api.jar; -d classes src/com/example/web/BeerSelect.java
After entering this I get the following message in the cmd:
javac: invalid flag: L\\Tomcat\apache-tomcat-8.0.28\lib\servlet-api.jar;
usage: javac <options><source files>
use- help for a list of possible options

I really do not know what to do here...Can someone point me in the right direction? My tomcat is running, and the form page and the web.xml is also fine (at least I think so)
All of the code from this first example I hard coded it in notepad and saved it with the right ext.
 
Tapas Chand
Ranch Hand
Posts: 583
8
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think space is not allowed in command line arguments in Windows.
You need to put the arguments with spaces in double quotes.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65339
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carlos L Sanchez wrote:I don’t think this should be even this hard, the fact that I am coding outside a compiler augments the difficulty of this problem.
I wonder why the author did not opt for just building
a project in eclipse or NetBeans and saved the new users all of the trouble?

Because a book that uses a particular IDE invariably becomes about that IDE and excludes those not using that IDE or no IDE at all. Also, use of an IDE is discouraged for newcomers to a technology as they hide too may details that people need to know.

He then instructs you to adapt this to your actual path which in my case is:
javac -cp C:\Users\Carlos L\Tomcat\apache-tomcat-8.0.28\lib\servlet-api.jar; -d classes src/com/example/web/BeerSelect.java


Yes, you need to escape embedded spaces in command lines. I avoid spaces in folder names just for this reason.
 
Carlos L Sanchez
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont even think that is the problem, the blank spaces are not even the issue. How can I make this work.
 
Carlos L Sanchez
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Carlos L Sanchez wrote:I don’t think this should be even this hard, the fact that I am coding outside a compiler augments the difficulty of this problem.
I wonder why the author did not opt for just building
a project in eclipse or NetBeans and saved the new users all of the trouble?

Because a book that uses a particular IDE invariably becomes about that IDE and excludes those not using that IDE or no IDE at all. Also, use of an IDE is discouraged for newcomers to a technology as they hide too may details that people need to know.

He then instructs you to adapt this to your actual path which in my case is:
javac -cp C:\Users\Carlos L\Tomcat\apache-tomcat-8.0.28\lib\servlet-api.jar; -d classes src/com/example/web/BeerSelect.java


Yes, you need to escape embedded spaces in command lines. I avoid spaces in folder names just for this reason.

All i see is that you made 3 comments, neither relevant to my original question. Can you please make a possitive contribution to my original question?
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carlos L Sanchez wrote:I dont even think that is the problem, the blank spaces are not even the issue. How can I make this work.


The error message says

After entering this I get the following message in the cmd:
javac: invalid flag: L\\Tomcat\apache-tomcat-8.0.28\lib\servlet-api.jar;


This is because you didn't put quotes around that path... but you've already decided that the earlier reply which said that was not relevant to your question. You are of course free to believe that but you aren't likely to get your problem fixed if you reject replies and insult the people who post them.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65339
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carlos L Sanchez wrote:
All i see is that you made 3 comments, neither relevant to my original question. Can you please make a possitive contribution to my original question?

Both are in direct response to your questions. If you are not interested in the answers, why pose the questions?

Also, you might want to review the CodeRanch "Be nice" policy.
 
Carlos L Sanchez
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Carlos L Sanchez wrote:
All i see is that you made 3 comments, neither relevant to my original question. Can you please make a possitive contribution to my original question?

Both are in direct response to your questions. If you are not interested in the answers, why pose the questions?

Also, you might want to review the CodeRanch "Be nice" policy.

I think that while youre at it you should review it yourself. It was you after all who started it all with comments who do not bring any benefits to the question at hand.
As for the people that answered, Thank you!, it solved my problem, it was the "" after all, sorry i seemed like a douche, was having a bad day.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65339
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carlos L Sanchez wrote:It was you after all who started it all with comments who do not bring any benefits to the question at hand.


Bear's 1st comment on the use of IDEs: in direct answer to Sanchez question "I wonder why the author did not opt for just building
a project in eclipse or NetBeans and saved the new users all of the trouble? "

Bear's 2nd comment on spaces in command lines: in direct answer to Sanchez question "I really do not know what to do here...Can someone point me in the right direction?"

You may not have wanted to hear my answers, but claiming that my replies are "neither relevant to my original question" is clearly misguided.

I think that while youre at it you should review it yourself.

Please point out any portion of my comments that could be construed as a violation of the "Be nice" policy. In fact, I urge you to complain about any such passages in the Ranch Office forum or to raise an issue with the owner of the site.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic