864 /** From: tob (tobin@telocity.com) Subject: different 'jdb' and 'java' behavior Newsgroups: comp.lang.java.help Date: 2000-09-13 15:43:39 PST hello, I'm trying to write some code that writes all the Instruments of the default Soundbank to a file. when i run the following code as an application with 'java MidiResourceApp', my Instrument[] array does not get filled. But when i run 'jdb' then 'run MidiResourceApp' the code acts as expected and i get a text file of the Instruments.. also, if you modify this program to run as an applet, it works as expected.. can anyone shed some light on this inconsistent behavior between applications, applets, and jdb? running JDK1.3 on a PC... thanks, tobin */ import javax.sound.midi.*; import java.io.*; public class MidiResourceApp { Synthesizer synthesizer; Instrument instruments[]; PrintWriter pw; FileWriter fw; MidiResourceApp() { try { fw = new FileWriter(new File("out.log")); pw = new PrintWriter(fw, true); } catch (IOException e) { System.out.println("cannot create file"); } } public void open() { try { if (synthesizer == null) { if ((synthesizer = MidiSystem.getSynthesizer()) == null) { System.out.println("getSynthesizer() failed!"); return; } } synthesizer.open(); } catch (Exception ex) { ex.printStackTrace(); return; } Soundbank sb = synthesizer.getDefaultSoundbank(); if (sb != null) { instruments = sb.getInstruments(); if (instruments.length == 0) { System.out.println("empty instruments[] array"); System.exit(0); } for(int i=0; i