Java能够进行进程监视吗? [英] Is Java capable of process monitoring?

查看:61
本文介绍了Java能够进行进程监视吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以用Java编写在托盘中运行的应用程序,当启动某个应用程序时,它可以检测到它?我想对某些程序执行此操作,以查明我每周使用它们有多长时间.我是Java的新手,所以我不知道Java是否是对此的最佳语言,或者Java是否具有适当的操作系统访问权限.

Is it possible to write an application in Java that runs in the tray and when a certain application is launched, it can detect it? I want to do this for certain programs to find out how long I use them for a weekly basis. I'm new to Java, so I don't know if Java is even the best language for this, or if it has the proper access to the operating system to do this.

推荐答案

Java本身并没有与特定于系统的功能进行太多集成(大多数其他通用语言也没有).如果您在谈论Windows,则选择的系统语言将是C#(或C/C ++).在Mac上,它将是ObjectiveC(或C/C ++).在Linux上,它将是C.

Java in itself does not have much integration into system-specific features (nor do most other general-purpose languages). If you're talking about windows, the system language of choice would be C# (or C/C++). On Mac, it'd be ObjectiveC (or C/C++). On linux, it'd be C.

要访问给定系统上的过程监视功能,您需要首先了解将要使用的API.然后,您可以评估给定的语言是否具有针对这些API的内置库或第三方库支持.

To access process monitoring facilities on a given system, you need to first understand the APIs you're going to be using. Then you can evaluate whether a given language has built-in or third-party library support for those APIs.

对于Java,您需要编写 JNI (C代码),请使用 JNA (仅Java) ,或解析 Runtime.exec()(调用各种系统/shell命令)以访问与管理和/或监视过程相关的系统API.

In the case of Java, you'd need to either write some JNI (C code), use JNA (Java only), or parse the output of Runtime.exec() (call various system/shell commands) to access the system APIs related to managing and/or monitoring processes.

这篇关于Java能够进行进程监视吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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