MidiUnavailableException using MidiSystem.getSequencer
I messed this up by accidentally answering this one: MidiUnavailableException in Java?
So, I am asking this question again. It is related to the one above.
I get an exceptio开发者_Go百科n when trying to use:
MidiSystem.getSequencer()
My code shows the following is present:
com.sun.media.sound.RealTimeSequencer@1ded0fd
I have tried all of the suggestions in the previous question. Does anyone know how to fix this problem?
I am using jdk 1.6.0_25-b06 and Ubuntu 11.04 with all current updates installed. I do not have JMF installed. The sequencer class is loaded. I have soundbank.gm in the audio directory under the jre. I have tried enabling and disabling lines in the sound.properties file. I have tried restarting my computer to be sure no other apps are using the sound system.
I get the following exception:
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
playmidi.PlayMidi.main(PlayMidi.java:57) 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) ... 4 more
The funny thing to me is that other apps (Banshee, RhythmBox, etc) can play midi files on my machine. I guess they have their own software sequencer (not sure).
Any help would be appreciated. Thanks!
Let's install alsa-oss. Than you can run your program with commands starting with "aoss" like:
aoss java -jar XXX
If you use eclipse, you can run it with aoss too. Than your code will work fine. I've just made an alias for it, for a symlink:
alias eclipse='LIBOVERLAY_SCROLLBAR=0 aoss eclipse-indigo &'
( LIBOVERLAY_SCROLLBAR is a solution for an other bug. There were some random crashes of jvm 2 or 3 / 10 hours. )
An other solution is when you install a built in java from the repository it would work as well
精彩评论