错误的方法:
//CPUID
private static final String cpuid="dmidecode -t processor | grep 'ID' | head -1";
Process p = Runtime.getRuntime().exec(cpuid);
原因:不会被再次解析,管道符失效
正确的办法:
linux下:
String[] command = { "/bin/sh", "-c", cpuid };
Process ps = Runtime.getRuntime().exec(command );
windows下:
String[] command = { "cmd", "/c", cpuid };
Process ps = Runtime.getRuntime().exec(command );