• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help getting started with Head First Java

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic