Java util prefs windows

Java.util.prefs.WindowsPreferences WARNING: Could not open/create prefs root node Software\JavaSoft\Pre

при работе с MIDI вылетает вот такое сообщение

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

из-за чего это получается и как это исправить?
код примерно такой

Player prefs
1.Если playerpreft.set. (*name*. ) И такое имя уже есть в списке,то ошибки ведь не будет и файл.

На разделах двух систем файл prefs.js Firefox-а один
На системном разделе старой системы Windows 7 файл «prefs.js» Firefox-а (и всё остальное) является.

Не получается сохранять уровень звука через Player Prefs
Есть слайдер, отвечающий за регулировку уровня звука. Слайдер является дочерним объектом панели.

Подмена выдачи браузера. Постоянная блокировка всплывающих окон. Malwarebytes находит prefs.js
Скачал и запустил что то не то. Malwarebytes нашёл кучу всего. Я всё удалил. Но prefs.js он.

Заказываю контрольные, курсовые, дипломные и любые другие студенческие работы здесь или здесь.

Java.util.concurrent.* или java.util.Stream
Как добавить библиотеку java.util.concurrent или java.util.Stream? Прошу, пожалуйста, помочь.

Аналоги java.util.ArrayList >
Подскажите, пожалуйста, аналоги java.util.ArrayList >, которые 1. либо.

Ошибка java.lang.ClassCastException: com.organizer.ToDoItemDescr cannot be cast to java.util.Map
Ошибка появляется когда пытаюсь вытянуть из кастомного адаптера запись ListView. Весь лог ошибки.

Считать атрибуты Root-Node в XML
Доброго времени суток! Столкнулся с проблемой, которая думаю не сложная, но все же. Покопался.

perl xmlSimple: как добавить атрибут к root node?
пытаюсь создать xml file с помощью перловой библиотеки XMLSimple. получается только так: .

Java util prefs windows

There are two separate trees of preference nodes, one for user preferences and one for system preferences. Each user has a separate user preference tree, and all users in a given system share the same system preference tree. The precise description of «user» and «system» will vary from implementation to implementation. Typical information stored in the user preference tree might include font choice, color choice, or preferred window location and size for a particular application. Typical information stored in the system preference tree might include installation configuration data for an application.

Nodes in a preference tree are named in a similar fashion to directories in a hierarchical file system. Every node in a preference tree has a node name (which is not necessarily unique), a unique absolute path name, and a path name relative to each ancestor including itself.

The root node has a node name of the empty string («»). Every other node has an arbitrary node name, specified at the time it is created. The only restrictions on this name are that it cannot be the empty string, and it cannot contain the slash character (‘/’).

The root node has an absolute path name of «/» . Children of the root node have absolute path names of «/» + . All other nodes have absolute path names of

+ «/» + . Note that all absolute path names begin with the slash character.

A node n‘s path name relative to its ancestor a is simply the string that must be appended to a‘s absolute path name in order to form n‘s absolute path name, with the initial slash character (if present) removed. Note that:

  • No relative path names begin with the slash character.
  • Every node’s path name relative to itself is the empty string.
  • Every node’s path name relative to its parent is its node name (except for the root node, which does not have a parent).
  • Every node’s path name relative to the root is its absolute path name with the initial slash character removed.

Note finally that:

  • No path name contains multiple consecutive slash characters.
  • No path name with the exception of the root’s absolute path name ends in the slash character.
  • Any string that conforms to these two rules is a valid path name.

All of the methods that modify preferences data are permitted to operate asynchronously; they may return immediately, and changes will eventually propagate to the persistent backing store with an implementation-dependent delay. The flush method may be used to synchronously force updates to the backing store. Normal termination of the Java Virtual Machine will not result in the loss of pending updates — an explicit flush invocation is not required upon termination to ensure that pending updates are made persistent.

Читайте также:  Psi для windows 64 bit

All of the methods that read preferences from a Preferences object require the invoker to provide a default value. The default value is returned if no value has been previously set or if the backing store is unavailable. The intent is to allow applications to operate, albeit with slightly degraded functionality, even if the backing store becomes unavailable. Several methods, like flush , have semantics that prevent them from operating if the backing store is unavailable. Ordinary applications should have no need to invoke any of these methods, which can be identified by the fact that they are declared to throw BackingStoreException .

The methods in this class may be invoked concurrently by multiple threads in a single JVM without the need for external synchronization, and the results will be equivalent to some serial execution. If this class is used concurrently by multiple JVMs that store their preference data in the same backing store, the data store will not be corrupted, but no other guarantees are made concerning the consistency of the preference data.

This class contains an export/import facility, allowing preferences to be «exported» to an XML document, and XML documents representing preferences to be «imported» back into the system. This facility may be used to back up all or part of a preference tree, and subsequently restore from the backup.

The XML document has the following DOCTYPE declaration: Note that the system URI (http://java.sun.com/dtd/preferences.dtd) is not accessed when exporting or importing preferences; it merely serves as a string to uniquely identify the DTD, which is: Every Preferences implementation must have an associated PreferencesFactory implementation. Every Java(TM) SE implementation must provide some means of specifying which PreferencesFactory implementation is used to generate the root preferences nodes. This allows the administrator to replace the default preferences implementation with an alternative implementation.

If the system property java.util.prefs.PreferencesFactory is defined, then it is taken to be the fully-qualified name of a class implementing the PreferencesFactory interface. The class is loaded and instantiated; if this process fails then an unspecified error is thrown.

If a PreferencesFactory implementation class file has been installed in a jar file that is visible to the system class loader , and that jar file contains a provider-configuration file named java.util.prefs.PreferencesFactory in the resource directory META-INF/services , then the first class name specified in that file is taken. If more than one such jar file is provided, the first one found will be used. The class is loaded and instantiated; if this process fails then an unspecified error is thrown.

Finally, if neither the above-mentioned system property nor an extension jar file is provided, then the system-wide default PreferencesFactory implementation for the underlying platform is loaded and instantiated.

Working with Windows registry using java.util.prefs.Preferences

I have some questions about the registry.
We have

it will return true.
After it:

We see that it has one child: «Windows». But

returns false. Why?

UPDATE

Ok. I have some mistakes. Let me try again: Why does

2 Answers 2

If you execute the code lines shown, in the order shown, when you get to the line

p does not anymore point to the user root, but to «/HKEY_CURRENT_USER/Software/Policies».

Btw you have a probable omission in your third code sample:

I stumbled on this one today. The answer you’ve accepted is completely wrong.

You seem to be under the impression that Java Preferences is a general tool to manipulate the Windows Registry. It is not. It just so happens that the default implementation of Preferences on the Windows platform happens to store its data in the Windows Registry.

The implementation on Windows stores stuff under the following Registry paths:

For systemRoot: HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs

For userRoot : HKEY_CURRENT_USER\Software\JavaSoft\Prefs

(note: The registry paths changes a bit if you are using a 32bit JRE on a 64-bit OS but that has nothing to do with Java and everything to do with Windows. Sun’s code always use the above paths.)

The point to make is that you can maybe use Java Preferences interface to read or change values in the Windows Registry but only below the above registry paths. The reason why I say ‘maybe’ is that this is just how it happens to be at the moment. Sun/Oracle could at any point in time decide to not to use the Windows Registry or use the Windows Registry but without using sub-nodes, i.e. store everything in one big XML string or something. The point is that Java Preferences is designed to shield you from this.

Читайте также:  Где находится файлы обновления windows 10

A lot of Java software that use the Java Preferences provide their own implementation (which is pretty simple to do) to avoid Sun’s default implementation that uses the Windows Registry. Not everyone can write to the Windows Registry these days so that was a pretty bad design decision on Sun’s part. Fortunately very easy to change.

Groovy Shell warning “Could not open/create prefs root node …”

I tried to open the Groovy Shell ( groovysh ) on Windows 8 and got the following output:

After printing the above message the shell started as expected.

9 Answers 9

Dennis answer is correct. However I would like to explain the solution in a bit more detailed way (for Windows User):

  1. Go into your Start Menu and type regedit into the search field.
  2. Navigate to path HKEY_LOCAL_MACHINE\Software\JavaSoft (Windows 10 seems to now have this here: HKEY_LOCAL_MACHINE\Software\WOW6432Node\JavaSoft )
  3. Right click on the JavaSoft folder and click on New -> Key
  4. Name the new Key Prefs and everything should work.

Alternatively, save and execute a *.reg file with the following content:

I was able to resolve the problem by manually creating the following registry key:

This is actually a JDK bug. It has been reported several times over the years, but only in 8139507 was it finally taken seriously by Oracle.

The problem was in the JDK source code for WindowsPreferences.java . In this class, both nodes userRoot and systemRoot were declared static as in:

This means that the first time the class is referenced both static variables would be initiated and by this the Registry Key for HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs (= system tree) will be attempted to be created if it doesn’t already exist.

So even if the user took every precaution in his own code and never touched or referenced the system tree, then the JVM would actually still try to instantiate systemRoot , thus causing the warning. It is an interesting subtle bug.

There’s a fix committed to the JDK source in June 2016 and it is part of Java9 onwards. There’s also a backport for Java8 which is in u202.

What you see is really a warning from the JDK’s internal logger. It is not an exception. I believe that the warning can be safely ignored . unless the user code is indeed wanting the system preferences, but that is very rarely the case.

Java util prefs windows

There are two separate trees of preference nodes, one for user preferences and one for system preferences. Each user has a separate user preference tree, and all users in a given system share the same system preference tree. The precise description of «user» and «system» will vary from implementation to implementation. Typical information stored in the user preference tree might include font choice, color choice, or preferred window location and size for a particular application. Typical information stored in the system preference tree might include installation configuration data for an application.

Nodes in a preference tree are named in a similar fashion to directories in a hierarchical file system. Every node in a preference tree has a node name (which is not necessarily unique), a unique absolute path name, and a path name relative to each ancestor including itself.

The root node has a node name of the empty string («»). Every other node has an arbitrary node name, specified at the time it is created. The only restrictions on this name are that it cannot be the empty string, and it cannot contain the slash character (‘/’).

The root node has an absolute path name of "/". Children of the root node have absolute path names of "/" + . All other nodes have absolute path names of

+ "/" + . Note that all absolute path names begin with the slash character.

Читайте также:  Radeon hd 5470m driver windows 10

A node n‘s path name relative to its ancestor a is simply the string that must be appended to a‘s absolute path name in order to form n‘s absolute path name, with the initial slash character (if present) removed. Note that:

  • No relative path names begin with the slash character.
  • Every node’s path name relative to itself is the empty string.
  • Every node’s path name relative to its parent is its node name (except for the root node, which does not have a parent).
  • Every node’s path name relative to the root is its absolute path name with the initial slash character removed.

Note finally that:

  • No path name contains multiple consecutive slash characters.
  • No path name with the exception of the root’s absolute path name ends in the slash character.
  • Any string that conforms to these two rules is a valid path name.

All of the methods that modify preferences data are permitted to operate asynchronously; they may return immediately, and changes will eventually propagate to the persistent backing store with an implementation-dependent delay. The flush method may be used to synchronously force updates to the backing store. Normal termination of the Java Virtual Machine will not result in the loss of pending updates — an explicit flush invocation is not required upon termination to ensure that pending updates are made persistent.

All of the methods that read preferences from a Preferences object require the invoker to provide a default value. The default value is returned if no value has been previously set or if the backing store is unavailable. The intent is to allow applications to operate, albeit with slightly degraded functionality, even if the backing store becomes unavailable. Several methods, like flush, have semantics that prevent them from operating if the backing store is unavailable. Ordinary applications should have no need to invoke any of these methods, which can be identified by the fact that they are declared to throw BackingStoreException .

The methods in this class may be invoked concurrently by multiple threads in a single JVM without the need for external synchronization, and the results will be equivalent to some serial execution. If this class is used concurrently by multiple JVMs that store their preference data in the same backing store, the data store will not be corrupted, but no other guarantees are made concerning the consistency of the preference data.

This class contains an export/import facility, allowing preferences to be «exported» to an XML document, and XML documents representing preferences to be «imported» back into the system. This facility may be used to back up all or part of a preference tree, and subsequently restore from the backup.

The XML document has the following DOCTYPE declaration: Note that the system URI (http://java.sun.com/dtd/preferences.dtd) is not accessed when exporting or importing preferences; it merely serves as a string to uniquely identify the DTD, which is: Every Preferences implementation must have an associated PreferencesFactory implementation. Every Java(TM) SE implementation must provide some means of specifying which PreferencesFactory implementation is used to generate the root preferences nodes. This allows the administrator to replace the default preferences implementation with an alternative implementation.

Implementation note: In Sun’s JRE, the PreferencesFactory implementation is located as follows:

If the system property java.util.prefs.PreferencesFactory is defined, then it is taken to be the fully-qualified name of a class implementing the PreferencesFactory interface. The class is loaded and instantiated; if this process fails then an unspecified error is thrown.

If a PreferencesFactory implementation class file has been installed in a jar file that is visible to the system class loader , and that jar file contains a provider-configuration file named java.util.prefs.PreferencesFactory in the resource directory META-INF/services, then the first class name specified in that file is taken. If more than one such jar file is provided, the first one found will be used. The class is loaded and instantiated; if this process fails then an unspecified error is thrown.

Finally, if neither the above-mentioned system property nor an extension jar file is provided, then the system-wide default PreferencesFactory implementation for the underlying platform is loaded and instantiated.

Оцените статью