WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5

时间:2023-03-08 15:38:17
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5

以下是我的程序(取自headfirst Java):

 import javax.sound.midi.*;

 public class MiniMiniMusicApp {
public static void main(String[] args) {
MiniMiniMusicApp mini = new MiniMiniMusicApp();
mini.play();
}
public void play() {
try {
Sequencer player = MidiSystem.getSequencer();
player.open(); Sequence seq = new Sequence(Sequence.PPQ, 4); Track track = seq.createTrack(); ShortMessage a = new ShortMessage();
a.setMessage(144, 1, 44, 100);
MidiEvent noteOn = new MidiEvent(a, 1);
track.add(noteOn); ShortMessage b = new ShortMessage();
b.setMessage(128, 1, 44, 100);
MidiEvent noteOff = new MidiEvent(b, 16);
track.add(noteOff); player.setSequence(seq); player.start();
} catch (Exception ex) {
ex.printStackTrace();
} }
}

在win8.1出现的错误信息如下:

WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0 
x80000002. Windows RegCreateKeyEx(...) returned error code 5.

解决方法如下:

Step1:搜索并运行regedit.exe

Step2: 进入HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft,右击JavaSoft目录,选择新建->项(key),命名为Prefs

Step3: 重新编译即可。