File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Whos reading the Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Whos reading the "Head First Java" book currently?" Watch "Whos reading the "Head First Java" book currently?" New topic
Author

Whos reading the "Head First Java" book currently?

Stuart Goss
Ranch Hand

Joined: Mar 21, 2001
Posts: 171
Hi there!

Is anybody on this forum reading the "Head First Java" book by Ms. Sierra and Mr. Bates currently?

I am just interested to find out, whether there are more beginners like me out there: "sharpening pencils", using "brain power", marshing through prep-code and having loads of fun while learning in a fantastic way?

Stuart
Adam Price
Ranch Hand

Joined: Nov 11, 2005
Posts: 95
Originally posted by Stuart Goss:
Hi there!

Is anybody on this forum reading the "Head First Java" book by Ms. Sierra and Mr. Bates currently?

I am just interested to find out, whether there are more beginners like me out there: "sharpening pencils", using "brain power", marshing through prep-code and having loads of fun while learning in a fantastic way?

Stuart



I am - I have gone up through the beginning of threads - then I paused to follow your lead on the Cattle Drive. It has been a great first introduction to Java for me. I did have one problem with the code, though. I talked about it here:
Modified Headfirst Beatbox

My next step with Head First will be to figure out how to solve a puzzle I set for myself with the beatbox.Random midi sequence

I have an idea of where to go - I just haven't attacked it since I am working on the cattledrive instead.

-Adam
Stuart Goss
Ranch Hand

Joined: Mar 21, 2001
Posts: 171
Wow Adam!

I flew over your Swing thread! I am just in chapter 6! You're way ahead of me!

Looking forward to seeing more of you on the Cattle Drive!

Stuart
Steve Stanicki
Greenhorn

Joined: Sep 24, 2005
Posts: 23
I am also pleased with what I have learned using Head First, especially on OOP. I am at the part of creating the Beat Box, and I have some problems.

I have typed in the code on page 420 - 423. It compiles fine, but I am getting a runtime error of

"Exception in thread "main" java.lang.NoClassDefFoundError: BeatBox/java"

I have tried several things with the constructor (new BeatBox2().buildGUI), and I have checked to see if I have a curly brace out of place somewhere.

But still get the same runtime error. I have even downloaded the code from wickedlysmart.com, but I still get the same runtime error.

Am I missing some errata? Please help.

Thanks,
Steve
Stuart Goss
Ranch Hand

Joined: Mar 21, 2001
Posts: 171
Hi Steve,

myke sure that you have compiled the code:

javac <ClassName>.java

(there you use the extension!)

and then are running the compiled class w/o using the .class extension and also w/o using the .java extension:

java <ClassName>

Come back with your results

Stuart
Steve Stanicki
Greenhorn

Joined: Sep 24, 2005
Posts: 23
Hi Stuart,
Thanks for replying so fast. Yes, I double checked, tried again, and I am still getting the runtime error. I am now wondering about the CLASSPATH variable, but I'm not clear on the concept. I am compiling and running from a different directory than before.

I set the path for the JDK when I installed it, so it compiles from anywhere. But I am wondering now about CLASSPATH, which I don't fully understand.

Thanks,
Steve
Lynn DePriest
Greenhorn

Joined: Nov 21, 2005
Posts: 7
I ran into problems initially with CLASSPATH as well. I think you answered your own question though when you stated that you are now running from a different directory than before. If you'll type the path of the new directory* into the variable value of your CLASSPATH (seperate from other stuff with ; if needed), then you should be able to run without getting that error. Hope this helps.

By the way, I am also currently going through the Head First Java book. I'm on chapter 7 and I absolutely love the way the book engages me. Chapter 6 was a bit of a head spinner for me though. All in all, it has been a great experience for me so far.

* assuming you're referring to this as the location where you're putting your class and java files.
Steve Stanicki
Greenhorn

Joined: Sep 24, 2005
Posts: 23
Hi Lynn,
Setting the CLASSPATH didn't help. I also went back to the basics and tried compiling and running "Hello World". It gave me the same runtime error.

I am running Windows XP Home, and recently defragged my hard drive.


As for the Head First book, I think it is the best computer book I have ever read. I had the chance to compare what one of my colleagues (we are both COBOL programmers), learned about Java in community college. I have learned (and now understand much clearer) OOP, while she learned mostly syntax.

I think I am going to remove and reinstall the JDK and JRE.

Thanks,
Steve
Steve Stanicki
Greenhorn

Joined: Sep 24, 2005
Posts: 23
Hi Lynn and Stuart,

Problem solved.

1. I downloaded fresh and uninstalled/installed a new JRE and JDK in case
of files missing or corrupted after defragging.
2. Simplified my directory structure.
3. Added the new CLASSPATH and PATH.
4. Moved Hello World and BeatBox to my new "working directory".
5. Recompiled and ran both successfully.

This leads me to ask the following questions:
1. As an experienced programmer, I consider these pretty harsh steps (a last resort on a mainframe for example), if this was a real world environment, how would this be fixed?

2. If I make other subdirectories under my new working directory, do I have to edit CLASSPATH everytime?

As long as I learned something (CLASSPATH) it's all good.

Thanks for your input,
Steve

"If we knew what we were doing, it wouldn't be research"
- Albert Einstein
John Zakrzewski
Greenhorn

Joined: Jan 06, 2006
Posts: 13
Absolutely wonderful book. It sortof forces you gently to think in classes and objects. Besides I love dogs and mine doesn't seem to mind me talking to him about the book. I think he's planning on classifying his preferred foods. Trouble is I don't see any dog/foods listed in his diagrams. I think it should be Foods/That He likes
Stuart Goss
Ranch Hand

Joined: Mar 21, 2001
Posts: 171
Originally posted by Steve Stanicki:
Problem solved.


Congrats, Steve!

4. Moved Hello World and BeatBox to my new "working directory".
5. Recompiled and ran both successfully.


.. could this have been causing the trouble all along?
Where were you running the "java BeatBox" command from?
... and where was the BeatBox.class?

... , if this was a real world environment, how would this be fixed?

I think your problem was with the classpath ...

2. If I make other subdirectories under my new working directory, do I have to edit CLASSPATH everytime?


if you want to work in C:\myjava\ as working dir and then make a new dir c:\myjava\another_project\ then just change into that dir for compiling and running the classes. If you're out for packaging your own classes based on a website you may have (e.g. "www.steve.com"), then make a dir c:\myjava\com\steve\ and compile the code in there. When the new classes are ready just put them wherever you like (as jar or still in the entire ".\com\steve\" dir structure. E.g. put them under c:\program_files\steves_java_classes\. Now you need to add the c:\program_files\steves_java_classes\ dir to your classpath variable, either in the PCs path variable or simply use "javac -classpath c:\program_files\steves_java_classes" on the command line


"If we knew what we were doing, it wouldn't be research"
- Albert Einstein


Hey, I wasn't sure that Einstein really said this, but I used it on the first page of my Diploma. I'm glad I wasn't mistaken.

Stuart
Chris Woodall
Greenhorn

Joined: Jan 07, 2006
Posts: 7
I have the book to, but I am having some problems in the beggining (this is my first language besides some basic applescript)
[ January 07, 2006: Message edited by: Chris Woodall ]
Stuart Goss
Ranch Hand

Joined: Mar 21, 2001
Posts: 171
Hi Chris,

why don't you come down to the "Cattle Drive", there you can learn Java online with more of us (you send in your attempts at *simple* projects and have them nitpicked by professionals, meanwhile you can ask any question you like in the Cattle Drive Forum).

The Cattle Drive Forum

Take a look, you'll find me and others there!

See you there, Stuart
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Steve Stanicki:
Hi Lynn and Stuart,

Problem solved.

1. I downloaded fresh and uninstalled/installed a new JRE and JDK in case
of files missing or corrupted after defragging.
2. Simplified my directory structure.
3. Added the new CLASSPATH and PATH.
4. Moved Hello World and BeatBox to my new "working directory".
5. Recompiled and ran both successfully.

This leads me to ask the following questions:
1. As an experienced programmer, I consider these pretty harsh steps (a last resort on a mainframe for example), if this was a real world environment, how would this be fixed?

2. If I make other subdirectories under my new working directory, do I have to edit CLASSPATH everytime?

As long as I learned something (CLASSPATH) it's all good.

Thanks for your input,
Steve

"If we knew what we were doing, it wouldn't be research"
- Albert Einstein


I suspect that the run time error was caused by a combination of problems with the CLASSPATH and running the "java <ClassName>" command from the incorrect directory. (At least, I assume that you are using the command line for now.)

Typically, you don't need to set the CLASSPATH to run basic applications. If you do have it set, you should be sure to include . (DOT) in order to run programs from the current directory. This way you won't need to modify the CLASSPATH if you decide to create a new directory for each project.

Layne


Java API Documentation
The Java Tutorial
Deb Wright
Greenhorn

Joined: Dec 06, 2005
Posts: 4
Hey guys,

I'm reading the Head First Java book as well as doing the Cattle Drive.

Did you type in the code for chapter 5 (SimpleDotCom)? I'm having a heck of a time getting anything to compile. Up to this point everything was going ok.

On the SimpleDotCom class, the compiler wouldn't accept the new "for" format, even after I updated to the latest version of Java and restarted. It thought the colon should be a semicolon. It also flags the "return result;" statement.

Anybody else get that, or have any suggestions?

Thanks,
Deb
Stuart Goss
Ranch Hand

Joined: Mar 21, 2001
Posts: 171
Deb,

I haven't tried, but you probably need to uninstall all other java sdks before you install java_5.

Try it out and tell us about it!

- Stuart
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
I recently bought, but not reading it as much as perusing it. I am a CS student with 4 classes that specifically use Java under my belt. I got it mainly to learn about the new 5.0 stuff.

It is a fun and enjoyable read, although I was quite disappointed with the Swing section. That section just doesn't live up to the rest of the book, that I have read so far. It is light on real world gui constructs, no mention of many common components, and the beatbox thing, while cool is more of a "whee! look what I can do", then a solid demo of GUI's. Oh, and weak coverage of layout managers and lacking any mention of the most powerful and confusing one hurts too. Hopefully they will make up for this lack and put out a HF Swing book.

Other then that, I loved it and bought Design Patterns and the Servlets book and loved them, with only minor gripes that in no way hurt the overall quality of those books. I spend most of my school time in C and C++, since my concentration is in network securiyu, and wish they published books in other languages/topics. Senior level CS books are booooring, and I have found HF books to be technically excellent and easy to learn from.


"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
Originally posted by Steve Stanicki:
1. As an experienced programmer, I consider these pretty harsh steps (a last resort on a mainframe for example), if this was a real world environment, how would this be fixed?


In a real world environment, you would probably be working with an IDE such as Eclipse and writing Ant build scripts for automation of the build and release process.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Originally posted by Rusty Shackleford:
It is a fun and enjoyable read, although I was quite disappointed with the Swing section. That section just doesn't live up to the rest of the book, that I have read so far. It is light on real world gui constructs, no mention of many common components, and the beatbox thing, while cool is more of a "whee! look what I can do", then a solid demo of GUI's. Oh, and weak coverage of layout managers and lacking any mention of the most powerful and confusing one hurts too. Hopefully they will make up for this lack and put out a HF Swing book.


You're right. To do Swing justice is a book in itself, and a thick one at that.


There is no emoticon for what I am feeling!
Adam Price
Ranch Hand

Joined: Nov 11, 2005
Posts: 95
Originally posted by Deb Wright:
Hey guys,

I'm reading the Head First Java book as well as doing the Cattle Drive.

Did you type in the code for chapter 5 (SimpleDotCom)? I'm having a heck of a time getting anything to compile. Up to this point everything was going ok.

On the SimpleDotCom class, the compiler wouldn't accept the new "for" format, even after I updated to the latest version of Java and restarted. It thought the colon should be a semicolon. It also flags the "return result;" statement.

Anybody else get that, or have any suggestions?

Thanks,
Deb


What platform are you using? IDE, or from the command line?
Stuart Goss
Ranch Hand

Joined: Mar 21, 2001
Posts: 171
Hi Deb,

you may need to be using

javac -source 1.5 YourAppName.java

to be able to use the Java5 "Looping over arrays" feature

Check it out and tell us about it.

Stuart
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Stuart Goss:
Hi Deb,
you may need to be using
javac -source 1.5 YourAppName.java
...

Or to verify what the default is, enter...

javac -version YourAppName.java

If this comes back with 1.5 and you're still having trouble, then I suggest starting a new thread that includes your code.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Deb Wright:
Hey guys,

I'm reading the Head First Java book as well as doing the Cattle Drive.

Did you type in the code for chapter 5 (SimpleDotCom)? I'm having a heck of a time getting anything to compile. Up to this point everything was going ok.

On the SimpleDotCom class, the compiler wouldn't accept the new "for" format, even after I updated to the latest version of Java and restarted. It thought the colon should be a semicolon. It also flags the "return result;" statement.

Anybody else get that, or have any suggestions?

Thanks,
Deb


Deb,

Welcome to the Ranch!

If you are still experiencing these problems, please start your own thread. You should post the code that you are trying to compile as well as teh complete error messages that you get. You should also tell us how you are compiling your program. There are plenty of people here that are glad to help. You should also check out our FAQ for suggestions on how to ask a good question. If you follow these suggestions, you will increase the chances of getting the answer you are looking for in a timely manner.

Layne
Deb Wright
Greenhorn

Joined: Dec 06, 2005
Posts: 4
Hi Stuart & Marc,

Thanks for the tips. I ended up uninstalling JRE & JDK 1.4.2. I installed the JDK for 1.5.0_06. Then I followed some advice I found from a Cattle Drive thread from the end of October (can't compile .java file). I added user variables of JAVA_HOME and Path as laid out at the end of that thread, and updated my Classpath & Path system variables. Then I restarted my machine.

That solved the problem I had with recognizing 1.5.

Now I am just getting cannot find symbol errors on class references in the game class. This may sound like a dumb question, but should the java code for the 3 classes (SimpleDotComGame, SimpleDotCom, and GameHelper) be in one file? I have them in separate files, and so compiled them separately.

Thanks again!

Deb
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Deb Wright:
...should the java code for the 3 classes (SimpleDotComGame, SimpleDotCom, and GameHelper) be in one file? I have them in separate files, and so compiled them separately...

I don't have the book so I don't know what's in these files, but in general it's a good practice to keep each class definition in its own file. (Each top-level public class (or interface) definition must be in its own file.) Unless there are packages specified, it should suffice to have these files in the same directory. If there are packages involved, then I suggest you start a new post to address this.

If you're still getting errors, post the code...
Curtis Brown
Greenhorn

Joined: Jan 10, 2006
Posts: 20
I tried starting with Java in a Nutshell, but it was putting me to sleep. Then I discovered Head First, it's a great alternate perspective into Java!

I've done a variety of scripting projects, starting with 4D on the Mac back in the mid-90s (and a few batch scripts in DOS.) I moved on the a few simple shell-scripts, as well as learning some OOP fundamentals, and then last year took up PHP.

So... most of my experience is in monolithic(ish) projects... nothing true OO ecept some low-level theory.

I only just got Head First yesterday, so I'm only up to page 60.

I'm trying to catch-up, though! I'll check out this Cattle Drive, soon, but for now I think I need to digest more of Head First!
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Deb Wright:
Hi Stuart & Marc,

Thanks for the tips. I ended up uninstalling JRE & JDK 1.4.2. I installed the JDK for 1.5.0_06. Then I followed some advice I found from a Cattle Drive thread from the end of October (can't compile .java file). I added user variables of JAVA_HOME and Path as laid out at the end of that thread, and updated my Classpath & Path system variables. Then I restarted my machine.

That solved the problem I had with recognizing 1.5.

Now I am just getting cannot find symbol errors on class references in the game class. This may sound like a dumb question, but should the java code for the 3 classes (SimpleDotComGame, SimpleDotCom, and GameHelper) be in one file? I have them in separate files, and so compiled them separately.

Thanks again!

Deb


Deb,

You should start your own thread to ask a specific question. Please look at my previous response in this thread for some suggestions of things you should include to help us answer your question.

Layne
Curtis Brown
Greenhorn

Joined: Jan 10, 2006
Posts: 20
Just a couple additional data-points on the whole "multiple versions of JDK" issue...

(for the record, I'm developing under Linux (Ubuntu))

The most current Ubuntu package for Java is v. 1.4.2, but I'm learning Java for the first time and wanted to go straight to 1.5 (1.5.0_06 is what I'm using)

Instead of messing with removing the old version, and clobbering it with the .bin file I can get from Sun, then having to deal with the inevitable Ubuntu migration to 1.5, I decided to leave 1.4.2 intact, and run 1.5 in parallel.

This should work fine in Windows too.

Basically, I created a ~/java/ folder (that's in my home directory, you could use C:\ I suppose in Windows) and unpacked the 1.5 files there.

Then, I altered my path so that 1.5 takes precedence to /usr/bin.

If I want to use 1.4.2 I just call it by it's full path (i.e. /usr/bin/javac) and it still works fine, but by default I can just type java or javac straight into my command-line and it uses 1.5

If anyone needs more details just let me know, I could go step-by-step if it's needed.

^CB
[ January 11, 2006: Message edited by: Curtis Brown ]
Stuart Goss
Ranch Hand

Joined: Mar 21, 2001
Posts: 171
Originally posted by Curtis Brown:
I tried starting with Java in a Nutshell, but it was putting me to sleep. Then I discovered Head First, it's a great alternate perspective into Java!

I started with the "Nutshell" too, about 5 years back (Java 1.1). But I learned from HeadFirst (HF) Java that it should be used as a reference book (just open it up and look at the classes in the API to get an overview of what the API can do).

I only just got Head First yesterday, so I'm only up to page 60.

You're really speeding, it's really worth doing the exerceises and sleeping over it all. Try it out. The longer you spend learning and thinking about it, the long it will stick!

I'm trying to catch-up, though! I'll check out this Cattle Drive, soon, but for now I think I need to digest more of Head First!

If you come to the Cattle Drive, you can only profit from our Cattle experience and all the mistakes we made with our assignments.

I look forward to seeing you there

Stuart
Curtis Brown
Greenhorn

Joined: Jan 10, 2006
Posts: 20
You're really speeding, it's really worth doing the exerceises and sleeping over it all. Try it out. The longer you spend learning and thinking about it, the long it will stick!


Too true! Given my background, I think the first 3 chapters went really fast because, for the most part, it already made sense to me... I have been doing all the exercises, and I'm pretty happy with my results, except perhaps for the puzzlers -- those are rather difficult for me.

I'm on the last excersise of chapter 3, we'll see if I can naturally keep up the pace for long before I get deep into new concepts and have to slow down to absorb it...

Also, this book is fairly entertaining, maybe I'll read it through a second time

Yes, I think the Nutshell book is far better as a reference than as a learning tome -- I think both books together (along with tutorials and forums online) should be adequite to build a strong foundation in Java.... Time will tell!
Tom Never
Greenhorn

Joined: Jan 11, 2006
Posts: 7
I just bought the book, and am only on page 14. And am having problems with 99 bottles of beer on the wall, which I will post separately.
Tom

Originally posted by Stuart Goss:
[QB]Hi there!

Is anybody on this forum reading the "Head First Java" book by Ms. Sierra and Mr. Bates currently?
 
Consider Paul's rocket mass heater.
 
subject: Whos reading the "Head First Java" book currently?
 
Similar Threads
SCJP 6
scbcd:help me out in preparing
Head First JSF?
Aparently the claspath or the path is not correctly set??
SCWCD