Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Head First Java Chapter 11 MiniMiniMusicApp

 
Martin Jansen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Martin Jansen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Martin Jansen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to Java in General.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic