*
The moose likes Beginning Java and the fly likes Head First Java P346 - MiniMusic Apps - hanging and not returning to the command line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Head First Java P346 - MiniMusic Apps - hanging and not returning to the command line" Watch "Head First Java P346 - MiniMusic Apps - hanging and not returning to the command line" New topic
Author

Head First Java P346 - MiniMusic Apps - hanging and not returning to the command line

marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

A quick question, I think.

I am running the MiniMusicCmdApp class below - it compiles and almost functions as expected, except after it makes the sound the class hangs (blinking cursor - see image), and I have to close down Command Prompt, reset my path etc when I reopen it.

Is this a bad class, or is there something wrong with my computer settings?

Thanks

Marten




EDIT by mw: Added Code Tags.
[ February 24, 2007: Message edited by: marc weber ]

when in doubt put it in parenthesis and stick a dollar sign in front of it, only good can come from this.
David McCombs
Ranch Hand

Joined: Oct 17, 2006
Posts: 212
I am not sure why it is hanging, but you can use cntl-c to force the program to shut down. Check the books website to see if there is a known problem in the code.

Sorry I couldn't be more helpful.
[ February 24, 2007: Message edited by: David McCombs ]

"Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration."- Stan Kelly-Bootle
marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

but you can use cntl-c to for the program to shut down


Thanks David, while it does not solve the problem, it does help a lot.

Marten
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

At the end of the try block (immediately after calling player.start();), try adding the following...

This will cause a 2-second pause (which should be long enough for the player to play the note you specified), after which it will close the Sequencer and exit the program.
[ February 25, 2007: Message edited by: marc weber ]

"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
marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

Thanks Marc, this did the trick and I am one step further on the OO journey. Not sure why they did not include in the book... probably did not want to confuse the message...
 
jQuery in Action, 2nd edition
 
subject: Head First Java P346 - MiniMusic Apps - hanging and not returning to the command line
 
Similar Threads
Head First Java Ch 11 Example
using MIDI classes: HF Java
Running Java Command LIne
Head First Java Chapter 11, example on page 346
Head First Java - Chapter 11 - MiniMusicCmdLine Error