I am having a problem compiling code copied from Head First
Java Edition 2. When I compile the class file that follows, I get the following compiler error:
"Cannot access Exception bad class file .\Exception.java. file does not contain class Exception. Please remove or make sure it appears in the correct subdirectory of the classpath.
catch (Exception ex) {ex.printStackTrace()}"
The code that I copied and tried to run follows. Thank you in advance for your help.
import javax.sound.midi.*;
public class MiniMusicPlayer1 {
public static void main (
String [] args) {
try {
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.open();
Sequence seq = new Sequence(Sequence.PPQ, 4);
Track track = seq.createTrack();
for (int i = 5; i < 61; i += 4) {
track.add(makeEvent(144,1,i,100,i));
track.add(makeEvent(128,1,i,100,i + 2));
}
sequencer.setSequencer(seq);
sequencer.setTempoInBPM(220);
sequencer.start();
}
catch (Exception ex) { ex.printStackTrace(); }
}
public static MidiEvent makeEvent (int comd, int chan, int one, int two, int tick) {
MidiEvent Event = null;
try {
ShortMessage a = new ShortMessage();
a.setMessage(comd, chan, one, two);
Event = new MidiEvent(a, tick);
}
catch (Exception e) {}
return Event;
}
}