Class WindowsVersion
Where the values come from. The Java VM gives os.name and os.version, and its os.version is "10.0" on Windows 10, on Windows 11 and on every Windows Server since 2016 alike. The build, its update revision (UBR), the release designation (DisplayVersion; ReleaseId on a Windows from before DisplayVersion existed) and the installation type (client or Server) are in the registry key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion. They are read with reg.exe query, one call per value and all started together, by the absolute path of reg.exe in the System32 directory of the Windows directory (no look-up along the path) and under one time limit. No other value of the key is read. The key's ProductName is of no use to tell Windows 10 from Windows 11: it says "Windows 10" on both.
The decision. A client is Windows 11 from build 22000 on and Windows 10 from build 10240 on. A Server is named by its build: 14393 is Windows Server 2016, 17763 is 2019, 20348 is 2022 and 26100 is 2025 (Microsoft's release information pages, read 2026-11-13). A Server of any other build is "Windows Server (build N)" and a client older than build 10240 is "Windows (build N)": a year or a name is never guessed. The release designation is what the registry holds, or empty: there is no table of builds and releases here, which every Windows release would make stale (and their order is not the order of the builds: 26H1 is build 28000, 26H2 is build 26300).
When the registry cannot be read (no reg.exe, the time limit, no build in its answer), the Java VM's own os.name and os.version are the answer, build is zero and problem says why.
Nothing here depends on another IIZI class: the static initializer of com.iizix.SystemConfig calls get(), so this class must never touch a class that needs SystemConfig.
- Author:
- Christopher Mindus
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intThe build, e.g.final booleanFlag for a Windows Server, false for a client.final StringWhy the registry could not be read,nullwhen it was read.final StringThe product: "Windows 10", "Windows 11", "Windows Server 2016", "Windows Server 2019", "Windows Server 2022", "Windows Server 2025", "Windows Server (build N)" for a Server of another build, "Windows (build N)" for a client older than Windows 10, or the Java VM'sos.namewhen the registry could not be read.final StringThe release designation as the registry holds it, e.g.final intThe update revision of the build (UBR), e.g.final floatThe version as a number to compare with: 10.0 for Windows 10 and Windows Server 2016 to 2022, 11.0 for Windows 11 and for Windows Server 2025 or newer.Method Summary
Modifier and TypeMethodDescriptionstatic WindowsVersionget()Gets the Windows version of this host.getName()Gets the name part of the descriptiontoString(): the product without a build, e.g.Gets the version part of the descriptiontoString(): the release designation when known and the build with its update revision when known, e.g.toString()Gets the description for a log line or a page: the product, the release designation when known, and the build with its update revision when known, e.g.
Field Details
isServer
public final boolean isServerFlag for a Windows Server, false for a client.product
The product: "Windows 10", "Windows 11", "Windows Server 2016", "Windows Server 2019", "Windows Server 2022", "Windows Server 2025", "Windows Server (build N)" for a Server of another build, "Windows (build N)" for a client older than Windows 10, or the Java VM'sos.namewhen the registry could not be read.release
The release designation as the registry holds it, e.g. "25H2", "24H2" or "1809"; empty when not known.build
public final int buildThe build, e.g. 26100; zero when the registry could not be read.revision
public final int revisionThe update revision of the build (UBR), e.g. 7171; -1 when not known.version
public final float versionThe version as a number to compare with: 10.0 for Windows 10 and Windows Server 2016 to 2022, 11.0 for Windows 11 and for Windows Server 2025 or newer. For a Windows older than Windows 10 it is the Java VM'sos.version(6.3 for Windows 8.1), and zero when that cannot be parsed.problem
Why the registry could not be read,nullwhen it was read.
Method Details
get
Gets the Windows version of this host. The registry is read at the first call only.- Returns:
- The version,
nullwhen this host is not Windows.
toString
Gets the description for a log line or a page: the product, the release designation when known, and the build with its update revision when known, e.g. "Windows 11 25H2 (build 26200.7171)", "Windows Server 2022 21H2 (build 20348.2700)" or "Windows Server 23H2 (build 25398.1085)". It isgetName()andgetVersionText()with a blank between them, so a page that shows the name and the version in two places shows this description.getName
Gets the name part of the descriptiontoString(): the product without a build, e.g. "Windows 11", "Windows Server 2022", or "Windows Server" for a Server whose build has no name here (its build is ingetVersionText()).- Returns:
- The name.
getVersionText
Gets the version part of the descriptiontoString(): the release designation when known and the build with its update revision when known, e.g. "25H2 (build 26200.7171)", "(build 25398.1085)" or "1809".- Returns:
- The version part; empty when neither a release designation nor a build is known (the registry could not be read).