Jan 14, 2017 10:44:54 PM java.util.prefs.WindowsPreferences WARNING: Could not open / create prefs root node Software \ JavaSoft \ Prefs at root 0x80000002. Windows RegCreateKeyEx (...) returned error code 5.

import javax.sound.midi.*; public class MiniMusicCmdLine { public static void main(String[] args) { MiniMusicCmdLine mini = new MiniMusicCmdLine(); int instrument = 80; int note = 20; mini.play(instrument , note); } public void play(int instrument, int note) { try { Sequencer player = MidiSystem.getSequencer(); player.open(); Sequence seq = new Sequence(Sequence.PPQ, 4); Track track = seq.createTrack(); MidiEvent event = null; ShortMessage first = new ShortMessage(); first.setMessage(192, 1, instrument, 0); MidiEvent changeInstrument = new MidiEvent(first, 1); track.add(changeInstrument); ShortMessage a = new ShortMessage(); a.setMessage(144, 1, note, 100); MidiEvent noteOn = new MidiEvent(a, 1); track.add(noteOn); ShortMessage b = new ShortMessage(); b.setMessage(128, 1, note, 100); MidiEvent noteOff = new MidiEvent(b, 1); track.add(noteOff); player.setSequence(seq); player.start(); } catch (Exception ex) { ex.printStackTrace(); } } } 

Is there something wrong with the arguments? I removed the check and the parsint method for the instrument and note arguments from Maine, replacing them with numbers .. for changing the instrument and the note .. gives an error .. but I don’t hear any sounds) The console program was initially .. but I changed the code in Maine and tried run it in IDEA, because I don’t understand how to run it through cmd

  • I suggest to try to compile Hello World - most likely the error will remain the same. If it does not, then it is worthwhile to provide a minimal reproducible example . Although, maybe this is minimal. - Qwertiy

1 answer 1

  1. Most likely, this is some kind of problem with the compiler. It may be worth reinstalling it. The error does not indicate the source code - we are talking about some registry key with settings.

  2. Error 5 is often a ban on access. You can try to run the command with admin rights.

  3. Actually, warning, not error. The program is not exactly compiled?

  4. Check the rights to the registry branch: Software\JavaSoft\Prefs .