#A Java library for accessing the power of the Windows Registry
This is a java wrapper for the Windows functions that operate on the registry. Some of the methods available in this library include read/write operations as well as the ability to search the registry for specific values. JRE 1.5 or higher required.
- Reading from / Writing to the Windows Registry
- Retrieving a sub-key listing as a sorted / unsorted array
- Iterating over sub-keys without using an array
- Retrieving a list of values as a sorted / unsorted array
- Iterating over values without using an array
- Copying whole registry sub-trees to another section of the registry
- Searching a sub-key for a specific value (can be a string or binary match)
- Listening for registry changes such as when a key or value is created or deleted
- Export a key to .reg file that is compatible with the Windows Registry Editor
Below are a few examples of how to use JRegistry. For a complete look at the library’s capabilities, take a look at the documentation. The
RegistryKey class contains the starting point for this library.
// Create a RegistryKey object with the root key as HKEY_CURRENT_USER RegistryKey software = new RegistryKey("SOFTWARE"); // software represents the path HKEY_CURRENT_USER\SOFTWARE // Can also include sub-keys RegistryKey myapp = new RegistryKey("SOFTWARE\\myapp"); // myapp represents the path HKEY_CURRENT_USER\SOFTWARE\myapp // If you need to create the key, add a second parameter with the value true RegistryKey myapp = new RegistryKey("SOFTWARE\\myapp", true); // Get a list of all the root keys RegistryKey roots = RegistryKey.listRoots(); // Get a list of values from the key List<RegistryValue> values = myapp.getValues(); // Get a single value RegistryValue value = myapp.getValue("name"); // Delete the key int code = myapp.deleteKey();