{"id":20741101,"url":"https://github.com/robtimus/windows-registry","last_synced_at":"2026-02-25T17:03:18.882Z","repository":{"id":57722453,"uuid":"441919211","full_name":"robtimus/windows-registry","owner":"robtimus","description":"Provides classes and interfaces for working with the Windows registry","archived":false,"fork":false,"pushed_at":"2025-05-11T14:51:10.000Z","size":1468,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-05T15:04:48.559Z","etag":null,"topics":["java","registry","windows","windows-registry"],"latest_commit_sha":null,"homepage":"https://robtimus.github.io/windows-registry/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robtimus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-12-26T15:08:32.000Z","updated_at":"2025-05-11T14:49:57.000Z","dependencies_parsed_at":"2023-02-16T10:46:31.345Z","dependency_job_id":"68eda6ae-2beb-4085-a7bc-49f5e068fabd","html_url":"https://github.com/robtimus/windows-registry","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/robtimus/windows-registry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fwindows-registry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fwindows-registry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fwindows-registry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fwindows-registry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robtimus","download_url":"https://codeload.github.com/robtimus/windows-registry/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fwindows-registry/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263792723,"owners_count":23512305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","registry","windows","windows-registry"],"created_at":"2024-11-17T06:33:47.369Z","updated_at":"2026-02-25T17:03:18.876Z","avatar_url":"https://github.com/robtimus.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# windows-registry\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.robtimus/windows-registry)](https://search.maven.org/artifact/com.github.robtimus/windows-registry)\n[![Build Status](https://github.com/robtimus/windows-registry/actions/workflows/build.yml/badge.svg)](https://github.com/robtimus/windows-registry/actions/workflows/build.yml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=com.github.robtimus%3Awindows-registry\u0026metric=alert_status)](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Awindows-registry)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=com.github.robtimus%3Awindows-registry\u0026metric=coverage)](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Awindows-registry)\n[![Known Vulnerabilities](https://snyk.io/test/github/robtimus/windows-registry/badge.svg)](https://snyk.io/test/github/robtimus/windows-registry)\n\nProvides classes and interfaces for working with the Windows registry.\n\n## Entry point\n\nThe entry point for accessing the Windows registry is method [Registry.local()](https://robtimus.github.io/windows-registry/apidocs/com.github.robtimus.os.windows.registry/com/github/robtimus/os/windows/registry/Registry.html#local\\(\\)). It returns a reference to the local Windows registry. This reference contains public fields for each of the available root registry keys. From these, use the `resolve` method to get the registry key you need. Note that registry key names can contain forward slashes, so you need to use backslashes to separate keys. From there you can access the registry key's sub keys and values.\n\n## Registry values\n\nUnlike several other libraries for working with the Windows registry, registry values are not returned as strings. Instead, class [RegistryValue](https://robtimus.github.io/windows-registry/apidocs/com.github.robtimus.os.windows.registry/com/github/robtimus/os/windows/registry/RegistryValue.html) defines several sub classes, one for each of the known registry value types. For instance, [StringValue](https://robtimus.github.io/windows-registry/apidocs/com.github.robtimus.os.windows.registry/com/github/robtimus/os/windows/registry/StringValue.html) is used for string values, [DWordValue](https://robtimus.github.io/windows-registry/apidocs/com.github.robtimus.os.windows.registry/com/github/robtimus/os/windows/registry/DWordValue.html) for DWORD (int) values, etc. This allows you to retrieve and set values using proper types, instead of having to convert everything to and from strings.\n\nIn addition to retrieving registry values as instances of `RegistryValue` or a sub class of `RegistryValue`, class `RegistryKey` provides some utility methods to retrieve registry values as string, DWORD (int) or QWORD (long), as these are considered the most used types.\n\n## Handles\n\nOperations can be directly called on registry keys. However, for non-root keys this opens a connection to the Windows registry for every operation. If you need to perform several operations on a single registry key, you should consider calling one of its `handle` methods. The returned handle allows you to perform the same operations with the same method signatures using a single connection to the Windows registry.\n\n## Transactions\n\nBy default, any interaction with the Windows registry does not use transactions. Using class [TransactionalState](https://robtimus.github.io/windows-registry/apidocs/com.github.robtimus.os.windows.registry/com/github/robtimus/os/windows/registry/TransactionalState.html) it's possible to run code within one of the following transactional states, based on Jakarta EE and Spring transactional states:\n\n* `TransactionalState mandatory` will reuse an existing transaction if present, or throw an exception otherwise.\n* `TransactionalState.required` will reuse an existing transaction if present, otherwise create a new one.\n* `TransactionalState.requiresNew` will create a new transaction.\n* `TransactionalState.supports` will use an existing transaction if present, otherwise work without a transaction.\n* `TransactionalState.notSupported` will ignore any existing transaction.\n* `TransactionalState.never` will throw an exception if an existing transaction is present.\n\nWhile nested transactions are not supported by Windows, nesting `TransactionalState` calls is supported. The innermost call will be leading for any interaction with the Windows registry. However, mixing different transactional states for the same registry keys may cause Windows to automatically rollback one or more transactions.\n\n### Committing and rolling back\n\nBy default, a transaction will be committed automatically when the `call` or `run` method that created it ends. By calling [Transaction.current()](https://robtimus.github.io/windows-registry/apidocs/com.github.robtimus.os.windows.registry/com/github/robtimus/os/windows/registry/Transaction.html#current\\(\\)) you can get access to the current transaction (if any). This allows you to query the transaction's status, turn auto-commit on or off, and explicitly commit or rollback the transaction.\n\n## Remote registries\n\nUsing method [Registry.at](https://robtimus.github.io/windows-registry/apidocs/com.github.robtimus.os.windows.registry/com/github/robtimus/os/windows/registry/Registry.html#at\\(java.lang.String\\)) you can connect to the Windows registry on a remote machine, provided the user the JVM is running as has the rights to do so. Apart from the entry point, remote registry keys work exactly like regular registry keys. This includes using the `resolve` method.\n\n### Using transactions with remote registries\n\nRemote registries will make use of the current transaction just like local registries, as long as Windows allows it. If needed, use `TransactionalState.notSupported` to ignore any existing transaction.\n\n## Implementation details\n\nInteraction with the Windows registry is done through the [Foreign Function and Memory (FFM) API](https://docs.oracle.com/en/java/javase/25/core/foreign-function-and-memory-api.html). This has some benefits:\n\n* Native interaction with the Windows registry instead of using commands like `REG QUERY` provides better performance.\n* Native interaction with the Windows registry instead of piggybacking on Java internal classes like `java.util.Preferences` provides greater compatibility between Java versions.\n* FFM is part of the Java core libraries. There is no need to install any libraries manually. There is not even need to install any runtime dependencies.\n\n### Enabling native access\n\nApplications will need to add JVM flag `--enable-native-access=com.github.robtimus.os.windows.registry`, or add `com.github.robtimus.os.windows.registry` to any already present `--enable-native-access` module list. If this flag is not present the current JVM versions will display a warning. That may change into a runtime error in later JVMs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobtimus%2Fwindows-registry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobtimus%2Fwindows-registry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobtimus%2Fwindows-registry/lists"}