Java,检查Windows上当前是否正在运行任何进程ID [英] Java, Checking if any process ID is currently running on Windows

查看:243
本文介绍了Java,检查Windows上当前是否正在运行任何进程ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Windows中检查Java中是否存在进程。

Is it possible to check the existence of process from Java in Windows.

我有可能的PID,我想知道它是否仍在运行。

I have its possible PID, I want to know if it is still running or not.

推荐答案

看看这是否有帮助:

http://blogs.oracle.com/vaibhav/entry/listing_java_process_from_java

该帖子解释了如何在Windows机器上运行所有PID:你必须将 cmd 调用的输出与PID进行比较而不是打印它。

That post explains how to get all PIDs running on a Windows machine: you'd have to compare the output of the cmd call with your PID, instead of printing it.

如果您使用的是类Unix系统,则必须使用 ps 而不是 cmd

If you're on Unix-like systems you'd have to use with ps instead of cmd

从java代码调用系统命令不是一个非常便携的解决方案;然后,流程的实施因操作系统而异。

Calling system commands from your java code is not a very portable solution; then again, the implementation of processes varies among operating systems.

这篇关于Java,检查Windows上当前是否正在运行任何进程ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆