不可杀死的java程序

发布于 2024-08-08 17:47:52 字数 57 浏览 3 评论 0原文

我用java开发了一个应用程序。 我需要我的 java 程序不会终止任何进程资源管理器/任务管理器。

I have developed an application in java.
I need that my java program would not terminated any process explorer/task manager.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

情泪▽动烟 2024-08-15 17:47:52

正如其他人所说,这是不可能的。 微软的 Raymond Chen 给出了很好的解释:为什么。

As others have said, this is not possible. Raymond Chen of Microsoft has given a good explanation as to why.

古镇旧梦 2024-08-15 17:47:52

不可能...

也许有方法可以从任务管理器甚至其他 Windows 专有进程资源管理器中隐藏它,但这需要访问本机 win32 API。

也许你可以使用 JNI(Java Native Interface)来实现这一点,但我仍然持怀疑态度。

&再加上JVM本身就是一个进程,当然可以被杀死。

Not possible...

There maybe ways to hide it from Task Manager or even other proprietary process explorers for windows but that needs access to the native win32 API.

Maybe you can use JNI(Java Native Interface) to achieve this but I am still skeptical.

& plus JVM itself is a process which can of-course be killed.

ぽ尐不点ル 2024-08-15 17:47:52

即使这是可能的,您甚至不应该想要(更不用说“需要”)这样做

它唯一能实现的就是激怒用户,并可能引发法律麻烦。没有正当理由这样做,所以不要这样做。

Even if this were possible, you should not even want (let alone "need") to do this.

The only thing it could achieve is piss off users and perhaps cause legal trouble. There is no legitimate reason to do it, so don't.

情域 2024-08-15 17:47:52

我相信这是不可能的。

操作系统应该始终能够管理应用程序,这可能涉及终止它们。

I believe it is not possible.

The OS should always be able to manage the application, which could involve terminating them.

深居我梦 2024-08-15 17:47:52

你可以看看rmid。我认为你可以让它在服务出现故障时自动重新启动。据我记得,这是 Jini 中经常使用的。

(所以这会给你一个外部看门狗,仅基于Java工具。当然问题是当 rmid 本身死掉时你要做什么。我想用 cron 做一些聪明的事情。但是如果 cron 死了怎么办?等等依此类推。)

You might take a look at rmid. I think you can make it automatically restart your service whenever it went down. As far as I recall, this is what was used in Jini a lot.

(So this would give you an external watch dog, based on Java tools only. Question of course is what you are going to do when rmid itself dies. I guess do something clever with cron. But what if cron dies? And so on and so forth.)

遮了一弯 2024-08-15 17:47:52

这是不可能的。

您能够实现的最接近的方法是向您的 Java 程序添加一个关闭挂钩,该挂钩将无限期地阻塞;例如Runtime.getRuntime().addShutdownHook(Thread)

这将导致 Posix 下的正常终止信号不起作用。从 Windows 任务管理器尝试“结束进程”将会失败,Windows 最终会提示该进程没有响应,您是否想要终止它 - 此时没有办法阻止终止。

This is not possible.

The closest you're able to achieve is to add a shut-down hook to your Java program that will block indefinitely; e.g. Runtime.getRuntime().addShutdownHook(Thread).

This will have the affect that a normal kill signal under Posix will have no effect. From Windows task manager an attempt to "End Process" will fail and Windows will eventually prompt stating that the process is unresponsive and would you like to terminate it - At this point there is no way to prevent the termination.

来日方长 2024-08-15 17:47:52

这在 VC++ 和其他语言中是可能的,因为您能够直接挂接到操作系统本身。 Java 程序总是通过 JVM 作为中间层,如果您能够通过 JVM 将其深入到某人的机器中,正如人们所说,这将是一个巨大的安全漏洞:

简短版本:如果您绝对必须这样做,使用编译本机二进制文件的语言来完成此操作,并且在您和操作系统 API 之间没有虚拟机。

It's possible in VC++ and other languages because you have the ability to hook directly into the OS itself. Java programs are always going through the JVM as an intermediate layer and if you were able to hook that deeply into someone's machine via JVM, as people have said, it would be an immense security hole:

Short version: If you absolutely must do that, do it in a language that compiles native binaries and has no VM between you and the OS API.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文