原文:http://kakaluyi.javaeye.com/blog/211492

最近做个项目,就是要取得cpu占有率等等的系统信息,一开始以为要用动态链接库了,但后来发现可以像下面这样做,不去调用jni,这样省去了很多看新技术的时间o(∩_∩)o...

在Java中,可以获得总的物理内存、剩余的物理内存、已使用的物理内存等信息,下面例子可以取得这些信息,并且获得在Windows下的内存使用率。
     首先编写一个MonitorInfoBean类,用来装载监控的一些信息,包括物理内存、剩余的物理内存、已使用的物理内存、内存使用率等字段,该类的代码如下:

Java代码
  1. package com.amgkaka.performance;
  2. /** *//**
  3. * 监视信息的JavaBean类.
  4. * @author  amg
  5. * @version 1.0
  6. * Creation date: 2008-4-25 - 上午10:37:00
  7. */
  8. public class MonitorInfoBean {
  9. /** *//** 可使用内存. */
  10. private long totalMemory;
  11. /** *//** 剩余内存. */
  12. private long freeMemory;
  13. /** *//** 最大可使用内存. */
  14. private long maxMemory;
  15. /** *//** 操作系统. */
  16. private String osName;
  17. /** *//** 总的物理内存. */
  18. private long totalMemorySize;
  19. /** *//** 剩余的物理内存. */
  20. private long freePhysicalMemorySize;
  21. /** *//** 已使用的物理内存. */
  22. private long usedMemory;
  23. /** *//** 线程总数. */
  24. private int totalThread;
  25. /** *//** cpu使用率. */
  26. private double cpuRatio;
  27. public long getFreeMemory() {
  28. return freeMemory;
  29. }
  30. public void setFreeMemory(long freeMemory) {
  31. this.freeMemory = freeMemory;
  32. }
  33. public long getFreePhysicalMemorySize() {
  34. return freePhysicalMemorySize;
  35. }
  36. public void setFreePhysicalMemorySize(long freePhysicalMemorySize) {
  37. this.freePhysicalMemorySize = freePhysicalMemorySize;
  38. }
  39. public long getMaxMemory() {
  40. return maxMemory;
  41. }
  42. public void setMaxMemory(long maxMemory) {
  43. this.maxMemory = maxMemory;
  44. }
  45. public String getOsName() {
  46. return osName;
  47. }
  48. public void setOsName(String osName) {
  49. this.osName = osName;
  50. }
  51. public long getTotalMemory() {
  52. return totalMemory;
  53. }
  54. public void setTotalMemory(long totalMemory) {
  55. this.totalMemory = totalMemory;
  56. }
  57. public long getTotalMemorySize() {
  58. return totalMemorySize;
  59. }
  60. public void setTotalMemorySize(long totalMemorySize) {
  61. this.totalMemorySize = totalMemorySize;
  62. }
  63. public int getTotalThread() {
  64. return totalThread;
  65. }
  66. public void setTotalThread(int totalThread) {
  67. this.totalThread = totalThread;
  68. }
  69. public long getUsedMemory() {
  70. return usedMemory;
  71. }
  72. public void setUsedMemory(long usedMemory) {
  73. this.usedMemory = usedMemory;
  74. }
  75. public double getCpuRatio() {
  76. return cpuRatio;
  77. }
  78. public void setCpuRatio(double cpuRatio) {
  79. this.cpuRatio = cpuRatio;
  80. }
  81. }
package com.amgkaka.performance;
/** *//**
* 监视信息的JavaBean类.
* @author  amg
* @version 1.0
* Creation date: 2008-4-25 - 上午10:37:00
*/
public class MonitorInfoBean {
/** *//** 可使用内存. */
private long totalMemory;
/** *//** 剩余内存. */
private long freeMemory;
/** *//** 最大可使用内存. */
private long maxMemory;
/** *//** 操作系统. */
private String osName;
/** *//** 总的物理内存. */
private long totalMemorySize;
/** *//** 剩余的物理内存. */
private long freePhysicalMemorySize;
/** *//** 已使用的物理内存. */
private long usedMemory;
/** *//** 线程总数. */
private int totalThread;
/** *//** cpu使用率. */
private double cpuRatio;
public long getFreeMemory() {
return freeMemory;
}
public void setFreeMemory(long freeMemory) {
this.freeMemory = freeMemory;
}
public long getFreePhysicalMemorySize() {
return freePhysicalMemorySize;
}
public void setFreePhysicalMemorySize(long freePhysicalMemorySize) {
this.freePhysicalMemorySize = freePhysicalMemorySize;
}
public long getMaxMemory() {
return maxMemory;
}
public void setMaxMemory(long maxMemory) {
this.maxMemory = maxMemory;
}
public String getOsName() {
return osName;
}
public void setOsName(String osName) {
this.osName = osName;
}
public long getTotalMemory() {
return totalMemory;
}
public void setTotalMemory(long totalMemory) {
this.totalMemory = totalMemory;
}
public long getTotalMemorySize() {
return totalMemorySize;
}
public void setTotalMemorySize(long totalMemorySize) {
this.totalMemorySize = totalMemorySize;
}
public int getTotalThread() {
return totalThread;
}
public void setTotalThread(int totalThread) {
this.totalThread = totalThread;
}
public long getUsedMemory() {
return usedMemory;
}
public void setUsedMemory(long usedMemory) {
this.usedMemory = usedMemory;
}
public double getCpuRatio() {
return cpuRatio;
}
public void setCpuRatio(double cpuRatio) {
this.cpuRatio = cpuRatio;
}
}

接着编写一个获得当前的监控信息的接口,该类的代码如下所示:

Java代码
  1. package com.amgkaka.performance;
  2. /** *//**
  3. * 获取系统信息的业务逻辑类接口.
  4. * @author amg * @version 1.0
  5. * Creation date: 2008-3-11 - 上午10:06:06
  6. */
  7. public interface IMonitorService {
  8. /** *//**
  9. * 获得当前的监控对象.
  10. * @return 返回构造好的监控对象
  11. * @throws Exception
  12. * @author amgkaka
  13. * Creation date: 2008-4-25 - 上午10:45:08
  14. */
  15. public MonitorInfoBean getMonitorInfoBean() throws Exception;
  16. }
package com.amgkaka.performance;
/** *//**
* 获取系统信息的业务逻辑类接口.
* @author amg * @version 1.0
* Creation date: 2008-3-11 - 上午10:06:06
*/
public interface IMonitorService {
/** *//**
* 获得当前的监控对象.
* @return 返回构造好的监控对象
* @throws Exception
* @author amgkaka
* Creation date: 2008-4-25 - 上午10:45:08
*/
public MonitorInfoBean getMonitorInfoBean() throws Exception;
}

该类的实现类MonitorServiceImpl如下所示:

Java代码
  1. package com.amgkaka.performance;
  2. import java.io.InputStreamReader;
  3. import java.io.LineNumberReader;
  4. import sun.management.ManagementFactory;
  5. import com.sun.management.OperatingSystemMXBean;
  6. /** *//**
  7. * 获取系统信息的业务逻辑实现类.
  8. * @author amg * @version 1.0 Creation date: 2008-3-11 - 上午10:06:06
  9. */
  10. public class MonitorServiceImpl implements IMonitorService {
  11. //可以设置长些,防止读到运行此次系统检查时的cpu占用率,就不准了
  12. private static final int CPUTIME = 5000;
  13. private static final int PERCENT = 100;
  14. private static final int FAULTLENGTH = 10;
  15. /** *//**
  16. * 获得当前的监控对象.
  17. * @return 返回构造好的监控对象
  18. * @throws Exception
  19. * @author amg     * Creation date: 2008-4-25 - 上午10:45:08
  20. */
  21. public MonitorInfoBean getMonitorInfoBean() throws Exception {
  22. int kb = 1024;
  23. // 可使用内存
  24. long totalMemory = Runtime.getRuntime().totalMemory() / kb;
  25. // 剩余内存
  26. long freeMemory = Runtime.getRuntime().freeMemory() / kb;
  27. // 最大可使用内存
  28. long maxMemory = Runtime.getRuntime().maxMemory() / kb;
  29. OperatingSystemMXBean osmxb = (OperatingSystemMXBean) ManagementFactory
  30. .getOperatingSystemMXBean();
  31. // 操作系统
  32. String osName = System.getProperty("os.name");
  33. // 总的物理内存
  34. long totalMemorySize = osmxb.getTotalPhysicalMemorySize() / kb;
  35. // 剩余的物理内存
  36. long freePhysicalMemorySize = osmxb.getFreePhysicalMemorySize() / kb;
  37. // 已使用的物理内存
  38. long usedMemory = (osmxb.getTotalPhysicalMemorySize() - osmxb
  39. .getFreePhysicalMemorySize())
  40. / kb;
  41. // 获得线程总数
  42. ThreadGroup parentThread;
  43. for (parentThread = Thread.currentThread().getThreadGroup(); parentThread
  44. .getParent() != null; parentThread = parentThread.getParent())
  45. ;
  46. int totalThread = parentThread.activeCount();
  47. double cpuRatio = 0;
  48. if (osName.toLowerCase().startsWith("windows")) {
  49. cpuRatio = this.getCpuRatioForWindows();
  50. }
  51. // 构造返回对象
  52. MonitorInfoBean infoBean = new MonitorInfoBean();
  53. infoBean.setFreeMemory(freeMemory);
  54. infoBean.setFreePhysicalMemorySize(freePhysicalMemorySize);
  55. infoBean.setMaxMemory(maxMemory);
  56. infoBean.setOsName(osName);
  57. infoBean.setTotalMemory(totalMemory);
  58. infoBean.setTotalMemorySize(totalMemorySize);
  59. infoBean.setTotalThread(totalThread);
  60. infoBean.setUsedMemory(usedMemory);
  61. infoBean.setCpuRatio(cpuRatio);
  62. return infoBean;
  63. }
  64. /** *//**
  65. * 获得CPU使用率.
  66. * @return 返回cpu使用率
  67. * @author amg     * Creation date: 2008-4-25 - 下午06:05:11
  68. */
  69. private double getCpuRatioForWindows() {
  70. try {
  71. String procCmd = System.getenv("windir")
  72. + "//system32//wbem//wmic.exe process get Caption,CommandLine,"
  73. + "KernelModeTime,ReadOperationCount,ThreadCount,UserModeTime,WriteOperationCount";
  74. // 取进程信息
  75. long[] c0 = readCpu(Runtime.getRuntime().exec(procCmd));
  76. Thread.sleep(CPUTIME);
  77. long[] c1 = readCpu(Runtime.getRuntime().exec(procCmd));
  78. if (c0 != null && c1 != null) {
  79. long idletime = c1[0] - c0[0];
  80. long busytime = c1[1] - c0[1];
  81. return Double.valueOf(
  82. PERCENT * (busytime) / (busytime + idletime))
  83. .doubleValue();
  84. else {
  85. return 0.0;
  86. }
  87. catch (Exception ex) {
  88. ex.printStackTrace();
  89. return 0.0;
  90. }
  91. }
  92. /** *//**
  93. * 读取CPU信息.
  94. * @param proc
  95. * @return
  96. * @author amg     * Creation date: 2008-4-25 - 下午06:10:14
  97. */
  98. private long[] readCpu(final Process proc) {
  99. long[] retn = new long[2];
  100. try {
  101. proc.getOutputStream().close();
  102. InputStreamReader ir = new InputStreamReader(proc.getInputStream());
  103. LineNumberReader input = new LineNumberReader(ir);
  104. String line = input.readLine();
  105. if (line == null || line.length() < FAULTLENGTH) {
  106. return null;
  107. }
  108. int capidx = line.indexOf("Caption");
  109. int cmdidx = line.indexOf("CommandLine");
  110. int rocidx = line.indexOf("ReadOperationCount");
  111. int umtidx = line.indexOf("UserModeTime");
  112. int kmtidx = line.indexOf("KernelModeTime");
  113. int wocidx = line.indexOf("WriteOperationCount");
  114. long idletime = 0;
  115. long kneltime = 0;
  116. long usertime = 0;
  117. while ((line = input.readLine()) != null) {
  118. if (line.length() < wocidx) {
  119. continue;
  120. }
  121. // 字段出现顺序:Caption,CommandLine,KernelModeTime,ReadOperationCount,
  122. // ThreadCount,UserModeTime,WriteOperation
  123. String caption = Bytes.substring(line, capidx, cmdidx - 1)
  124. .trim();
  125. String cmd = Bytes.substring(line, cmdidx, kmtidx - 1).trim();
  126. if (cmd.indexOf("wmic.exe") >= 0) {
  127. continue;
  128. }
  129. // log.info("line="+line);
  130. if (caption.equals("System Idle Process")
  131. || caption.equals("System")) {
  132. idletime += Long.valueOf(
  133. Bytes.substring(line, kmtidx, rocidx - 1).trim())
  134. .longValue();
  135. idletime += Long.valueOf(
  136. Bytes.substring(line, umtidx, wocidx - 1).trim())
  137. .longValue();
  138. continue;
  139. }
  140. kneltime += Long.valueOf(
  141. Bytes.substring(line, kmtidx, rocidx - 1).trim())
  142. .longValue();
  143. usertime += Long.valueOf(
  144. Bytes.substring(line, umtidx, wocidx - 1).trim())
  145. .longValue();
  146. }
  147. retn[0] = idletime;
  148. retn[1] = kneltime + usertime;
  149. return retn;
  150. catch (Exception ex) {
  151. ex.printStackTrace();
  152. finally {
  153. try {
  154. proc.getInputStream().close();
  155. catch (Exception e) {
  156. e.printStackTrace();
  157. }
  158. }
  159. return null;
  160. }
  161. /** *//**
  162. * 测试方法.
  163. * @param args
  164. * @throws Exception
  165. * @author amg     * Creation date: 2008-4-30 - 下午04:47:29
  166. */
  167. public static void main(String[] args) throws Exception {
  168. IMonitorService service = new MonitorServiceImpl();
  169. MonitorInfoBean monitorInfo = service.getMonitorInfoBean();
  170. System.out.println("cpu占有率=" + monitorInfo.getCpuRatio());
  171. System.out.println("可使用内存=" + monitorInfo.getTotalMemory());
  172. System.out.println("剩余内存=" + monitorInfo.getFreeMemory());
  173. System.out.println("最大可使用内存=" + monitorInfo.getMaxMemory());
  174. System.out.println("操作系统=" + monitorInfo.getOsName());
  175. System.out.println("总的物理内存=" + monitorInfo.getTotalMemorySize() + "kb");
  176. System.out.println("剩余的物理内存=" + monitorInfo.getFreeMemory() + "kb");
  177. System.out.println("已使用的物理内存=" + monitorInfo.getUsedMemory() + "kb");
  178. System.out.println("线程总数=" + monitorInfo.getTotalThread() + "kb");
  179. }
  180. }
package com.amgkaka.performance;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import sun.management.ManagementFactory;
import com.sun.management.OperatingSystemMXBean;
/** *//**
* 获取系统信息的业务逻辑实现类.
* @author amg * @version 1.0 Creation date: 2008-3-11 - 上午10:06:06
*/
public class MonitorServiceImpl implements IMonitorService {
//可以设置长些,防止读到运行此次系统检查时的cpu占用率,就不准了
private static final int CPUTIME = 5000;
private static final int PERCENT = 100;
private static final int FAULTLENGTH = 10;
/** *//**
* 获得当前的监控对象.
* @return 返回构造好的监控对象
* @throws Exception
* @author amg     * Creation date: 2008-4-25 - 上午10:45:08
*/
public MonitorInfoBean getMonitorInfoBean() throws Exception {
int kb = 1024;
// 可使用内存
long totalMemory = Runtime.getRuntime().totalMemory() / kb;
// 剩余内存
long freeMemory = Runtime.getRuntime().freeMemory() / kb;
// 最大可使用内存
long maxMemory = Runtime.getRuntime().maxMemory() / kb;
OperatingSystemMXBean osmxb = (OperatingSystemMXBean) ManagementFactory
.getOperatingSystemMXBean();
// 操作系统
String osName = System.getProperty("os.name");
// 总的物理内存
long totalMemorySize = osmxb.getTotalPhysicalMemorySize() / kb;
// 剩余的物理内存
long freePhysicalMemorySize = osmxb.getFreePhysicalMemorySize() / kb;
// 已使用的物理内存
long usedMemory = (osmxb.getTotalPhysicalMemorySize() - osmxb
.getFreePhysicalMemorySize())
/ kb;
// 获得线程总数
ThreadGroup parentThread;
for (parentThread = Thread.currentThread().getThreadGroup(); parentThread
.getParent() != null; parentThread = parentThread.getParent())
;
int totalThread = parentThread.activeCount();
double cpuRatio = 0;
if (osName.toLowerCase().startsWith("windows")) {
cpuRatio = this.getCpuRatioForWindows();
}
// 构造返回对象
MonitorInfoBean infoBean = new MonitorInfoBean();
infoBean.setFreeMemory(freeMemory);
infoBean.setFreePhysicalMemorySize(freePhysicalMemorySize);
infoBean.setMaxMemory(maxMemory);
infoBean.setOsName(osName);
infoBean.setTotalMemory(totalMemory);
infoBean.setTotalMemorySize(totalMemorySize);
infoBean.setTotalThread(totalThread);
infoBean.setUsedMemory(usedMemory);
infoBean.setCpuRatio(cpuRatio);
return infoBean;
}
/** *//**
* 获得CPU使用率.
* @return 返回cpu使用率
* @author amg     * Creation date: 2008-4-25 - 下午06:05:11
*/
private double getCpuRatioForWindows() {
try {
String procCmd = System.getenv("windir")
+ "//system32//wbem//wmic.exe process get Caption,CommandLine,"
+ "KernelModeTime,ReadOperationCount,ThreadCount,UserModeTime,WriteOperationCount";
// 取进程信息
long[] c0 = readCpu(Runtime.getRuntime().exec(procCmd));
Thread.sleep(CPUTIME);
long[] c1 = readCpu(Runtime.getRuntime().exec(procCmd));
if (c0 != null && c1 != null) {
long idletime = c1[0] - c0[0];
long busytime = c1[1] - c0[1];
return Double.valueOf(
PERCENT * (busytime) / (busytime + idletime))
.doubleValue();
} else {
return 0.0;
}
} catch (Exception ex) {
ex.printStackTrace();
return 0.0;
}
}
/** *//**
* 读取CPU信息.
* @param proc
* @return
* @author amg     * Creation date: 2008-4-25 - 下午06:10:14
*/
private long[] readCpu(final Process proc) {
long[] retn = new long[2];
try {
proc.getOutputStream().close();
InputStreamReader ir = new InputStreamReader(proc.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
String line = input.readLine();
if (line == null || line.length() < FAULTLENGTH) {
return null;
}
int capidx = line.indexOf("Caption");
int cmdidx = line.indexOf("CommandLine");
int rocidx = line.indexOf("ReadOperationCount");
int umtidx = line.indexOf("UserModeTime");
int kmtidx = line.indexOf("KernelModeTime");
int wocidx = line.indexOf("WriteOperationCount");
long idletime = 0;
long kneltime = 0;
long usertime = 0;
while ((line = input.readLine()) != null) {
if (line.length() < wocidx) {
continue;
}
// 字段出现顺序:Caption,CommandLine,KernelModeTime,ReadOperationCount,
// ThreadCount,UserModeTime,WriteOperation
String caption = Bytes.substring(line, capidx, cmdidx - 1)
.trim();
String cmd = Bytes.substring(line, cmdidx, kmtidx - 1).trim();
if (cmd.indexOf("wmic.exe") >= 0) {
continue;
}
// log.info("line="+line);
if (caption.equals("System Idle Process")
|| caption.equals("System")) {
idletime += Long.valueOf(
Bytes.substring(line, kmtidx, rocidx - 1).trim())
.longValue();
idletime += Long.valueOf(
Bytes.substring(line, umtidx, wocidx - 1).trim())
.longValue();
continue;
}
kneltime += Long.valueOf(
Bytes.substring(line, kmtidx, rocidx - 1).trim())
.longValue();
usertime += Long.valueOf(
Bytes.substring(line, umtidx, wocidx - 1).trim())
.longValue();
}
retn[0] = idletime;
retn[1] = kneltime + usertime;
return retn;
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
proc.getInputStream().close();
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
/** *//**
* 测试方法.
* @param args
* @throws Exception
* @author amg     * Creation date: 2008-4-30 - 下午04:47:29
*/
public static void main(String[] args) throws Exception {
IMonitorService service = new MonitorServiceImpl();
MonitorInfoBean monitorInfo = service.getMonitorInfoBean();
System.out.println("cpu占有率=" + monitorInfo.getCpuRatio());
System.out.println("可使用内存=" + monitorInfo.getTotalMemory());
System.out.println("剩余内存=" + monitorInfo.getFreeMemory());
System.out.println("最大可使用内存=" + monitorInfo.getMaxMemory());
System.out.println("操作系统=" + monitorInfo.getOsName());
System.out.println("总的物理内存=" + monitorInfo.getTotalMemorySize() + "kb");
System.out.println("剩余的物理内存=" + monitorInfo.getFreeMemory() + "kb");
System.out.println("已使用的物理内存=" + monitorInfo.getUsedMemory() + "kb");
System.out.println("线程总数=" + monitorInfo.getTotalThread() + "kb");
}
}

该实现类中需要用到一个自己编写byte的工具类,该类的代码如下所示:

Java代码
  1. package com.amgkaka.performance;
  2. /** *//**
  3. * byte操作类.
  4. * @author amg * @version 1.0
  5. * Creation date: 2008-4-30 - 下午04:57:23
  6. */
  7. public class Bytes {
  8. /** *//**
  9. * 由于String.subString对汉字处理存在问题(把一个汉字视为一个字节),因此在
  10. * 包含汉字的字符串时存在隐患,现调整如下:
  11. * @param src 要截取的字符串
  12. * @param start_idx 开始坐标(包括该坐标)
  13. * @param end_idx   截止坐标(包括该坐标)
  14. * @return
  15. */
  16. public static String substring(String src, int start_idx, int end_idx){
  17. byte[] b = src.getBytes();
  18. String tgt = "";
  19. for(int i=start_idx; i<=end_idx; i++){
  20. tgt +=(char)b[i];
  21. }
  22. return tgt;
  23. }
  24. }
package com.amgkaka.performance;
/** *//**
* byte操作类.
* @author amg * @version 1.0
* Creation date: 2008-4-30 - 下午04:57:23
*/
public class Bytes {
/** *//**
* 由于String.subString对汉字处理存在问题(把一个汉字视为一个字节),因此在
* 包含汉字的字符串时存在隐患,现调整如下:
* @param src 要截取的字符串
* @param start_idx 开始坐标(包括该坐标)
* @param end_idx   截止坐标(包括该坐标)
* @return
*/
public static String substring(String src, int start_idx, int end_idx){
byte[] b = src.getBytes();
String tgt = "";
for(int i=start_idx; i<=end_idx; i++){
tgt +=(char)b[i];
}
return tgt;
}
}

运行下MonitorBeanImpl类,读者将会看到当前的内存、cpu利用率等信息

wmic很强大,网上有很多wmic的命令,

eg:wmic 获取物理内存
wmic memlogical get TotalPhysicalMemory

wmic 获取进程信息,很详细

wmic process

System.getProperty("os.name"));//得到操作系统名字 
System.getProperty("sun.os.patch.level");//得到操作系统版本

java 获取系统信息及CPU的使用率相关推荐

  1. Java 获取系统信息

    Java 获取系统信息可以用以下方法: public class testsysteminfo {public static void main(String[] args) {// TODO Aut ...

  2. java获取系统信息:java的信息、操作系统的信息、用户的信息、虚拟机的信息、系统设置的信息。

    全栈工程师开发手册 (作者:栾鹏) java教程全解 java获取系统信息:java的信息.操作系统的信息.用户的信息.虚拟机的信息.系统设置的信息. package com.lp.app.windo ...

  3. Java获取Aix系统cpu和内存使用率

    背景 需要增加熔断功能,但是之前写的是linux系统,在Aix系统中失效了,需要重新写. 原来的linux用的是/proc/meminfo./proc/stat这两个文件进行监控的,但是Aix中没有这 ...

  4. java获取服务器的cpu和内存使用率

    使用的是sigar.jar包 sigar.jar下载地址密码1j2r 使用方法这三个文件放到jdk安装目录的bin下: Sigar sigar = new Sigar();Mem mem = siga ...

  5. c#获取系统信息:CPU、内存、硬盘、用户、网络

    全栈工程师开发手册 (作者:栾鹏) c#教程全解 c#获取cpu.内存.硬盘.用户.系统等的信息. 另外还包括:系统路径.window路径.cpu的id号.设备硬件卷号.本机MAC地址.邻节点MAC地 ...

  6. Java获取linux服务器cpu、内存、硬盘相关信息

    需要用到jcraft依赖,如果依赖失效,请前往官方获取jcraft官网,maven地址https://search.maven.org/artifact/com.jcraft/jsch <dep ...

  7. 关于Java获取系统信息

    一 .获取系统相关参数 java 通过System.getProperties()获取系统参数 Properties props=System.getProperties(); //系统属性 1 pu ...

  8. java 获取本机信息,使用Java获取系统信息的常用代码整理总结

    1.获取CPU和内存信息 ? 2.获取本机的IP地址: ? 3.获得网卡地址 ? 4.获得操作系统帐号 ? 5.获得操作系统版本 ? 6.一些常用的信息获得方式整理 java.version    J ...

  9. java获取系统信息

    转载:http://blog.csdn.net/kongqz/article/details/3987198 java.version Java 运行时环境版本 java.vendor Java 运行 ...

最新文章

  1. 记忆的天空:智能进化三部曲
  2. 稀疏矩阵之python实现
  3. pjsip for Android的编译
  4. 4固定在底部_礼堂椅厂家教你如何固定座椅
  5. Spring Cloud构建微服务架构:分布式服务跟踪(入门)【Dalston版】
  6. char[] 和char*之间的相互转换
  7. SpringBoot : BeanFactory
  8. 01-C#入门(分支控制语句)
  9. python消费kafka逻辑处理导致cpu升高_Kafka 消费迟滞监控工具 Burrow
  10. 系统类配置(四)【ubuntu14.04中安装英伟达驱动解决分辨率低的问题】
  11. linux 下 maven 安装配置
  12. javaSE基础篇之char
  13. Day11 JaseSE File类的使用
  14. PMP学习笔记 第11章 项目风险管理
  15. 原生JS【fiveKeyPress】2秒内五次点击键盘任意键(或组合键)触发自定义事件(以Pause/Break键为例)
  16. CCF认证 201712-4 行车路线(100分)
  17. ssh提示IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY解决
  18. 怎么成为游戏建模师?
  19. 《科技创业启示录》一第3章 拉尔斯·欣里希斯
  20. 设计mysql表实现 好友列表、昵称设置、好友分组

热门文章

  1. tensorflow中contrib模块问题。(tf.contrib)
  2. BVH树simple
  3. 建模杂谈系列100 数据工厂
  4. 香蕉好处多 但吃香蕉要注意这些禁忌!
  5. 微软应用商店隐私策略
  6. 如何把视频声音转成文字
  7. docker run 提示 refusing to operate on /etc/resolv.conf: unknown.
  8. RePlugin集成AndroidAutoSize
  9. 提高扫地机器人避障能力,景联文科技提供专业数据采集服务
  10. JavaCV - 灰度图像归一化到0-255