The Java Sound API, first introduced in J2SE 1.3, includes the package
javax.sound.midi, which contains everything you need to be able to send and
receive messages to and from any MIDI device visible to your operating
system.
The Java Sound Programmer Guide and the Java Sound Demo, both available for
download from Sun, are excellent references that illustrate all the "nuts and
bolts" of sending and receiving messages. This article provides a brief
overview of working with the MIDI and sampled audio primitives of the Java
Sound API, and then explores using those primitives to construct a basic
multi-track MIDI/audio sequencer in Java.
Programming with MIDI
Basically, every message you send to or receive from a MIDI device is one or
more bytes. The first byte is referred ... (more)