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

Head First Java Chapter 11 MiniMiniMusicApp

Martin Jansen
Greenhorn

Joined: Oct 22, 2010
Posts: 9
I am learning Java with the book Head FIrst Java second edition. Now, i am at chapter 11 and want to run the MiniMiniMusicApp.java program.
I get an error :
javax.sound.midi.MidiUnavailableException
at javax.sound.midi.MidiSystem.getDefaultDeviceWrapper(MidiSystem.java:1078)
at javax.sound.midi.MidiSystem.getReceiver(MidiSystem.java:240)
at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:442)
at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:348)
at MiniMiniMusicApp.play(MiniMiniMusicApp.java:10)
at MiniMiniMusicApp.main(MiniMiniMusicApp.java:45)
Caused by: java.lang.IllegalArgumentException: Requested device not installed
at javax.sound.midi.MidiSystem.getDefaultDevice(MidiSystem.java:1130)
at javax.sound.midi.MidiSystem.getDefaultDeviceWrapper(MidiSystem.java:1076)
... 5 more

I have installed Java JDK 1.6.0.21 on Ubuntu. Is this a well-known problem or do i miss some files?
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Martin Jansen welcome to JR!
It's difficult to answer the question without the book, because, everyone here don't have the book right now. So, please post the question!


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Martin Jansen
Greenhorn

Joined: Oct 22, 2010
Posts: 9
Ok, this is the program i have typed in from the book:

No compiler errors, but at runtime the error as i have written above.

Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Please => UseCodeTags when you post a code snaps! Use the EDIT button and insert the code tags there! It'll be more readable!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19790
    
  20

Your code works fine on my Windows XP machine. That makes me believe the issue is OS related. The error message says "Requested device not installed". Do you have a working sound device?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Martin Jansen
Greenhorn

Joined: Oct 22, 2010
Posts: 9
Yes, i use an Asus Eee PC 1201N with well working sound. But i think i must look further to the sound device of my netbook.
Martin Jansen
Greenhorn

Joined: Oct 22, 2010
Posts: 9
Finally I found a solution (workaround) to run my java program MiniMiniMusicApp on Ubuntu. It seems that Java 1.6 don't support PulseAudio, the audiodevice is already opened by another application or it is a permission problem .
With the command: padsp java MiniMiniMusicApp it works!

(padsp starts the specified program and redirects its access to OSS compatible audio devices (/dev/dsp and auxiliary devices) to a PulseAudio sound server).
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Moved to Java in General.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Head First Java Chapter 11 MiniMiniMusicApp