What causes the following warning/error message? And how to get rid of it?
Dec 31, 2021 3:10:05 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
I have a class NotePlayer.java and a test program NotePlayerTest.java, and when I run the latter, it runs ok, but I get the above warning message, which I would like to rectify.
A snippet of NotePlayer:
import javax.sound.midi.*;
public class NotePlayer {
/**
* Program: NotePlayer.java
* Purpose: Simple musical note player, plays a single note.
* Creator: Chris Clarke
* Created: July 2007
*/
MidiChannel[] mc;
Synthesizer synth;
Instrument[] instr;
int tmpo = 500; // fixed tempo of 120 beats/minute
boolean done = false;
public void loadInstr() {
// only necessary to run this method once
if (done) return;
for (int voice=0; voice<16; voice++) {
try {
synth = MidiSystem.getSynthesizer();
synth.open();
mc = new MidiChannel[16];
mc = synth.getChannels();
instr = synth.getDefaultSoundbank() .getInstruments();
synth.loadInstrument (instr[voice]); // 0-15
}
catch (Exception e) { System.out.println("Caught exception"); }
}
done = true;
} // end loadInstr()
public void playNote(int voice, int pitch, int duration, int vol) {
// play note
mc[voice].noteOn(pitch, vol);
for (int i=0; i<duration; i++) {
try {
Thread.sleep(tmpo/4); // pause for one semiquaver
} catch (InterruptedException e) {}
}
// stop playing note
mc[voice].noteOff(pitch, vol);
} // end playNote(int, int, int, int)
And my NotePlayerTest.java is as follows:
public class NotePlayerTest {
/**
* Program: NotePlayerTest.java by Chris Clarke
* Created: 04 July 2007
* Purpose: Test my NotePlayer class
*/
public static void main(String[] args) {
NotePlayer np = new NotePlayer();
np.loadInstr();
// parameters are voice (0-15), pitch, duration, volume
np.playNote(2, 42, 4, 600);
np.playNote(2, 46, 4, 600);
np.playNote(2, 49, 4, 600);
}
}