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: 重新编译即可。

上一篇:SQL Server 2012安装错误案例:Error while enabling Windows feature: NetFx3, Error Code: -2146498298


下一篇:获取bing图片并自动设置为电脑桌面背景(C++完整开源程序)