阻止用户终止java程序?

发布于 2024-12-11 03:58:23 字数 638 浏览 1 评论 0原文

我想在计算机上安装一个监控系统(该程序是一个jar文件)并在每次用户登录时启动它。但是,我不希望用户能够终止它,因为那样它将无法再被监视。

我们尝试了几种方法:

  • 将其安装为服务 - 这里的问题是我们的程序不再工作;它无法连接到监视它的计算机。为此,我们使用了“Yet Another Java Service Wrapper”,并研究了一些其他包装器,它们可以帮助我们将其安装为服务。

  • 在启动时运行程序(使用文件夹启动),但不授予基本用户编辑/删除/弄乱文件的权限。然而,这似乎降低了整个计算机的速度?当我们直接运行执行 jar 的 bat 文件时,不会发生这种情况。另一个问题是用户可以转到任务管理器并终止 java 进程。

  • 我们尝试了前一个的变体,通过使用另一个进程来解决进程被终止的问题。一个进程会产生另一个进程,这两个进程将相互监视。如果其中一个终止,另一个会检测到它并运行它以再次启动它。尽管如果用户在再次重生之前足够快地杀死两个进程,它可能会出现问题,但更大的问题是它有时会在连接到其他计算机时出现问题。当它只有 1 个 jar 时,我们没有遇到这个问题。

有谁知道如何解决这些问题?

这里的上下文是 Windows,但是如果您对 linux 和 mac 有建议,那就太好了!

I want to install a monitoring system on a computer (the program is a jar file) and run it on start up every time any user logs on. However, I don't want the user to be able to terminate it since then it won't be able to be monitored any longer.

We have tried several ways:

  • Installing it as a service - the problem here is that our program doesn't work any longer; it can't connect to the computer that's monitoring it. We used "Yet Another Java Service Wrapper" for this, and looked into some other wrappers as well that could help us install it as a service.

  • Running the program on start up (using the folder startup), but not giving the basic user the privileges to edit/delete/mess around with the files. However, this seems to slow the whole computer down? This doesn't happen when we run the bat file executing the jar directly. Another issue with this is that the user can just go to the task manager and kill the java process.

  • We tried a variation of the previous one to solve the issue of the process being killed, by having another process. One will spawn the other and these 2 processes will keep tabs on each other. If one terminates, the other detects it and runs it to start it up again. Although it can have issues if the user is fast enough in killing both processes before either is respawned again, the bigger issue is that it sometimes has problems with connecting to other computers. We didn't have this problem when it was just 1 jar.

Does anyone have any idea on how these problems can be solved?

The context here is windows, but if you have suggestions for linux and mac that would be nice too!

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

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

发布评论

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

评论(2

心安伴我暖 2024-12-18 03:58:23

方法是将程序作为服务运行。您应该调查应用程序和系统防火墙之间的任何问题。如果您激活了 Windows 防火墙,则应为 java.exe 或 javaw.exe 添加例外。

为了向您的程序授予更高的权限,您可以将服务设置为以其他用户身份运行。您可以通过服务属性中的“登录”选项卡执行此操作。

服务属性

Way to go is to run the program as a service. You should investigate any trouble between your application and your system's firewall. If you have windows firewall activated, you should add an exception for java.exe or javaw.exe.

In order to give elevated privileges to your program, you can set the service to run as another user. You can do this from the "Log on" tab in the service properties.

Service properties

沒落の蓅哖 2024-12-18 03:58:23

您需要在具有提升权限的用户下启动该程序。在 WIndows 上,这将是管理员,在 linux 上,这将使用 root。在 Windows 上,您可能需要将其作为服务启动。但我真的不知道为什么这会阻碍网络通信。

You'll want to have the program started under a user with elevated permissions. On WIndows this would the the Administrator, linux would use root. On Windows, its likely that you will need to start it as a service. But I really don't know why that would hinder the network communications.

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