• Post Reply Bookmark Topic Watch Topic
  • New Topic

Head First Java- Guessing Game  RSS feed

 
Keano Denton
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am very new to programming period. I have a copy of Head First Java, and I love it!! I have other programming books for dummies and they are so boring compared to this one. I had one question. I am on the Guessing Game exercise and I have created 3 different files for the game. My question is, is as long as those 3 files are in the same folder it will run fine? So if I were to create something else with multiple classes. As long as they are compiled into the same folder they will find each other and the program will run fine? I'm sorry for the very greenhorn question but this exercise has me very confused.
 
Mauro Trevigno
Ranch Hand
Posts: 99
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there!

Yes, it should run fine.

Are you using an IDE?

If not you can compile the 3 files doing the following:
javac -cp ./ maiin.java file2.java file3.java

Then just run
java maiin and should work properly.



Here is a link for more information about how to compile a file:
http://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html

Thanks & Regards,
Mauro.
 
Keano Denton
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much!!

No I am not using an IDE. I am using text editor, and terminal on a Mac.

I'm hoping further along in the book it gets into packaging them all together.

Also thanks for the link it is very helpful!!
 
Marshall Brett
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An IDE will speed the process up quite a bit. It shows you mistakes and offers suggestions for correcting them, and (if you're using NetBeans or Eclipse) will show you descriptions for methods etc. It even brings up lists of things you can do with objects! And, when you compile/run it will display the output in a window within the IDE.
 
Stuie Clarky
Ranch Hand
Posts: 98
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey there,

Have a quick search about the 'package' and 'import' statements. As a basic definition, these allow you to reflect the location of a file in your directory structure(package) and where the program should look to find the other classes(import). I don't remember if Head First covers this at some point, but there are lots of resources online that will allow you to get an idea of how it works


S
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An IDE also hides a lot of the details from you. Most people here would recommend NOT using an IDE if you are just learning java so that you get a firm understanding of the basics.

Also, if you start with something like Eclipse, then you end up learning Eclipse, not Java, and if you then go to a shop that uses something else, your kind of hosed.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!