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]
Did you try :
System.getProperty("os.version");
If you want to check the same on Linux or Android you can do so by this statement:
Runtime.getRuntime().exec("uname -r");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.