title: MidiUnavailableException in Java?
body: <p>I'm having some trouble playing MIDI files in Java. What I get is a <code>MidiUnavailableException (MIDI OUT transmitter not available)</code> when I try to play it. My code is standard:</p>
  
  <pre><code>try {
      midiseq = MidiSystem.getSequencer();
      midiseq.open();
      midiseq.setSequence(MidiSystem.getSequence(sound1));
      midiseq.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
      midiseq.start();
  } catch (Exception e) {e.printStackTrace();}
  </code></pre>
  
  <p><code>midiseq</code> is a <code>Sequencer</code>; <code>sound1</code> is an <code>InputStream</code>.</p>
  
  <p>This code works on several other computers, and even works in Eclipse and when used in a JAR file, just not when I launch it from the command prompt. I've downloaded a more stable Java midi application, and it threw the same exception.</p>
  
  <p>It can't be a hardware problem because Eclipse can run it without problems, neither can it be a coding problem because this runs correctly on other computers. Even this one line of code throws this exception:</p>
  
  <pre><code>javax.sound.midi.MidiSystem.getSequencer();
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p>edit: My operating system is Windows Vista. Before I asked this question I've downloaded the latest JRE and JDK (1.6.0_13 I think).</p>
  
  <p>edit: The code:</p>
  
  <pre><code>ClassLoader.getSystemClassLoader().loadClass("com.sun.media.sound.RealTimeSequencer");
  System.out.println( "Sequencer class loaded" );// Otherwise ClassNotFoundException
  </code></pre>
  
  <p>prints "Sequencer class loaded."</p>
  
  <p>But this code:</p>
  
  <pre><code>  try{
          System.out.println(javax.sound.midi.MidiSystem.getSequencer());
          System.exit(0);
        } catch(Exception e) {
          throw new RuntimeException(e);
        }
        System.exit(1);
  </code></pre>
  
  <p>throws the <code>MidiUnavailableException.</code></p>
  
  <p>Also, this code:</p>
  
  <pre><code>    MidiDevice.Info[] devices = MidiSystem.getMidiDeviceInfo();
      if (devices.length == 0) {
          System.out.println("No MIDI devices found");
      } else {
          for (MidiDevice.Info dev : devices) {
              System.out.println(dev);
          }
      }
  </code></pre>
  
  <p>gives me this:</p>
  
  <pre>
      Microsoft MIDI Mapper
      Microsoft GS Wavetable Synth
      Real Time Sequencer
      Java Sound Synthesizer
  </pre>