• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help getting started with Head First Java  RSS feed

 
Barb Beiswenger
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

This is my first time posting, so please be patient with me

Anyway, I have the Head First Java book and someone supposedly did the "Setting up Java" (xxviii Intro) for me. I just reached pg 17 where I'm supposed to write code, but the book doesn't really explain what I'm supposed to do. I created the source file, named it filename.java and saved it in the folder that the terminal defaults to, but I can't figure out how to run it. I thought I was supposed to type %javac filename.java in the terminal window, but I get an error message saying "%javac is not recognized as an internal or external command, operable program or batch file."

Can anyone tell me how I can run the file (or if I've made other mistakes)?

Thanks
Barb

 
Campbell Ritchie
Marshal
Posts: 56522
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

When you said %javac did you mean to include the % sign, or is that the prompt? It should read javac.
A lot of people get confused about setting up Java™ because there are more steps than installing a typical application on Windows®, etc. [Actually similar problems occur on other operating systems; the “cannot be recognised” is specific to Windows®.] We have an FAQ which should answer all your questions. If you get the HelloWorld program to run (only it says something like “moo” not “Hello World”), you have set up Java™ correctly. The step which causes the most confusion is setting the PATH. Don’t set a classpath at this stage.

Then the real problems like programming errors start!
 
Randall Twede
Ranch Hand
Posts: 4696
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
perhaps this is your confusion javac command compiles the file(program) for example "javac First.java". to run it you would type "java First"
 
Barb Beiswenger
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Welcome to the Ranch

Thanks!

Campbell Ritchie wrote:When you said %javac did you mean to include the % sign, or is that the prompt? It should read javac.

Actually, I later tried it without the % and it compiled, but the program didn't run.

Campbell Ritchie wrote:The step which causes the most confusion is setting the PATH. Don’t set a classpath at this stage.

My Java instructor from school set the path up and he ran a tested it and worked. And when I ran it, it did compile, but it didn't print anything. Any idea what the problem is?

Campbell Ritchie wrote: We have an FAQ which should answer all your questions. If you get the HelloWorld program to run (only it says something like “moo” not “Hello World”), you have set up Java™ correctly.

I will take a look at that, thanks.

My last question (for the moment) is can I go through the book using an IDE or does the structure of the book require doing it from the command line?

Thanks for all your help!!
Barb
 
Barb Beiswenger
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Randall Twede wrote:perhaps this is your confusion javac command compiles the file(program) for example "javac First.java". to run it you would type "java First"

Wow, thanks. I just went back and found those "instructions" -- they could have been clearer that those were commands that needed to be put in the command line :-/

Thanks again!!
Barb
 
sangram nani
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Barb Beiswenger wrote:
My last question (for the moment) is can I go through the book using an IDE or does the structure of the book require doing it from the command line?

Thanks for all your help!!
Barb


For best practices and to get a good grip on the java syntaxes command line exercise would be recommended.

--
all the best
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!