I want to get the kernel version in Windows using Java. Is there any class in Java to get the info?
I am able to find the OS name using System.getProperty("os.name");, but I want the kernel version instead.
With the ver command you can get a more precise kernel version (if needed)
You can execute it using cmd and then parse it
final String dosCommand = "cmd /c ver";
final String location = "C:\\WINDOWS\\SYSTEM32";
try {
final Process process = Runtime.getRuntime().exec(
dosCommand + " " + location);
final InputStream in = process.getInputStream();
int ch;
while((ch = in.read()) != -1) {
System.out.print((char)ch);
}
} catch (IOException e) {
e.printStackTrace();
}
Result (example)
Microsoft Windows [Version 6.1.7601]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With