这个标题几乎总结了这个问题。我找到的唯一的事情是this 但是我不确定那是不是这样。
答案 0 :(得分:12)
您可以使用wmic实用程序检查正在运行的进程列表 假设您要检查Windows的explorer.exe进程是否正在运行:
String line;
try {
Process proc = Runtime.getRuntime().exec("wmic.exe");
BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream()));
OutputStreamWriter oStream = new OutputStreamWriter(proc.getOutputStream());
oStream .write("process where name='explorer.exe'");
oStream .flush();
oStream .close();
while ((line = input.readLine()) != null) {
System.out.println(line);
}
input.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
请参阅http://ss64.com/nt/wmic.html或http://support.microsoft.com/servicedesks/webcasts/wc072402/listofsampleusage.asp了解您可以从wmic获得的一些示例......
答案 1 :(得分:2)
os.name应该这样做。更多信息here
答案 2 :(得分:2)
取决于您需要了解的内容!
大多数信息都可以从默认运行时属性派生,而无需实际检查操作系统属性。
查看http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperties()提供的内容:
java.version Java Runtime Environment version
java.vendor Java Runtime Environment vendor
java.vendor.url Java vendor URL
java.home Java installation directory
java.vm.specification.version Java Virtual Machine specification version
java.vm.specification.vendor Java Virtual Machine specification vendor
java.vm.specification.name Java Virtual Machine specification name
java.vm.version Java Virtual Machine implementation version
java.vm.vendor Java Virtual Machine implementation vendor
java.vm.name Java Virtual Machine implementation name
java.specification.version Java Runtime Environment specification version
java.specification.vendor Java Runtime Environment specification vendor
java.specification.name Java Runtime Environment specification name
java.class.version Java class format version number
java.class.path Java class path
java.library.path List of paths to search when loading libraries
java.io.tmpdir Default temp file path
java.compiler Name of JIT compiler to use
java.ext.dirs Path of extension directory or directories
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator ("/" on UNIX)
path.separator Path separator (":" on UNIX)
line.separator Line separator ("\n" on UNIX)
user.name User's account name
user.home User's home directory
user.dir User's current working directory
答案 3 :(得分:0)
您正在尝试确定您创建的流程是否仍在运行?
答案 4 :(得分:0)
我没有在非基于Windows的系统中尝试过。 也许4的PID可分性将提供一个线索 有关此PID属性的更多信息,请访问:About the pid of the process
在这里 http://blogs.msdn.com/oldnewthing/archive/2008/02/28/7925962.aspx