本文整理汇总了Java中oshi.software.os.OperatingSystem.getVersion方法的典型用法代码示例。如果您正苦于以下问题:Java OperatingSystem.getVersion方法的具体用法?Java OperatingSystem.getVersion怎么用?Java OperatingSystem.getVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oshi.software.os.OperatingSystem
的用法示例。
在下文中一共展示了OperatingSystem.getVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOperatingSystemInfo
import oshi.software.os.OperatingSystem; //导入方法依赖的package包/类
@Test
public void getOperatingSystemInfo() {
OshiPlatformCache oshi = newOshiPlatformCache();
OperatingSystem os = oshi.getOperatingSystem();
Assert.assertNotNull(os);
String family = os.getFamily();
String manu = os.getManufacturer();
OperatingSystemVersion version = os.getVersion();
Assert.assertNotNull(family);
Assert.assertNotNull(manu);
Assert.assertNotNull(version);
print("===OPERATION SYSTEM==");
print(" Family=[%s]", family);
print(" Manufacturer=[%s]", manu);
print(" Version=[%s](%s)", version, version.getClass());
print(" toString=[%s]", os.toString());
}
示例2: getSystemParameters
import oshi.software.os.OperatingSystem; //导入方法依赖的package包/类
private static String getSystemParameters() {
try {
SystemInfo si = new SystemInfo();
OperatingSystem os = si.getOperatingSystem();
HardwareAbstractionLayer hal = si.getHardware();
int megabyte = 1024 * 1024;
return "\n==========================System=========================" + "\r\n" +
"System:" + "\r\n" +
"\tOS: " + os.getManufacturer() + " " + os.getFamily() + " " +
os.getVersion() + " x" + getRealSystemArch() + "\r\n" +
"Hardware:" + "\r\n" +
"\tProcessors: " + Runtime.getRuntime().availableProcessors() + "\r\n" +
"\tTotal JVM memory: " + Runtime.getRuntime().maxMemory() / megabyte + " MB " +
"free:" + Runtime.getRuntime().freeMemory() / megabyte + " MB \r\n" +
"Java:" + "\r\n" +
"\tJava version: " + System.getProperty("java.specification.version") + "(" +
System.getProperty("java.version") + ")" + "\r\n" +
"\t" + System.getProperty("java.runtime.name") + " v" +
System.getProperty("java.vm.version") + "\r\n" +
"=========================================================" + "\r\n";
} catch (Exception e) {
log.warn("Could not show system parameters, proceeding", e);
return "";
}
}