用于为 Java UI 应用程序创建服务的 Java 服务包装器

问题描述:

我创建了一个需要作为服务运行的 Java 应用程序.对于服务包装器,我尝试使用 tanuki 和其他包装器软件.现在,我的应用程序确实作为服务运行 - 但是,它在 SYSTEM 下作为服务运行,而不是在当前登录的用户下运行.

I have created a Java application which needs to run as a service. For service wrapper I tried using tanuki and other wrapper softwares. Now, my application does run as a service - however, it runs as a service under SYSTEM and not under currently logged in user.

我的应用程序有一个 UI,当应用程序作为服务运行时不显示.我怀疑是否发生了这种情况,因为该服务在 SYSTEM 下运行,而不是在当前登录的用户下运行.当我运行应用程序(没有将其安装为服务)时,UI 确实出现了,我可以看到在当前用户的 ID 下运行的 java 进程,而作为服务安装时它在 SYSTEM 下运行.

My application has a UI, which does not show when the application is running as a service. I doubt that this has happened because the service is running under SYSTEM and not under currently logged in user. When I run the application (without installing it as a service), the UI does show up and I could see the java process running under the current user's id, whereas it runs under SYSTEM when installed as a service.

现在,如果没有 UI,我的应用程序就没有任何内容.我需要应用程序在系统启动时作为服务运行,并且还需要显示 UI.

Now, there is nothing to my application if there is no UI. I need to application to run as a service when the system boots up and the UI needs to show up as well.

有没有人尝试过我在这里做的事情并遇到过类似的问题.如果是这样,你是如何解决的?是否有不同的包装服务可供我使用并且没有此问题.

Has anyone tried to do what I am doing here and has faced a similar issue. If so, how did you go about resolving it? Is there a different wrapper service that I could use and not have this issue.

Tanuki 的文档确实解释了将 Java 应用程序设置为服务,但没有讨论带有 UI 的 Java 应用程序并在当前登录的用户下运行它.

Tanuki's documentation does explain setting a java application as a service, but does not talk about a java applicaiton with a UI and running it under the currently logged in user.

更新

只是为了让这里的人可以更多地了解我想要完成的任务 - 我尝试使用我的应用程序的行为类似于 Dropbox 或 Yahoo Messenger 或任何其他软件具有从 Windows 启动并继续在后台运行,允许用户使用系统托盘图标与其交互.所以基本上所有这些都是用 Java/Swing 构建的.现在,当涉及到应用程序的部署时 - 我可以独立运行它但运行 jar 文件或通过为它创建和运行一个可执行的包装器.但是,我希望该软件从 Windows 启动开始并继续在后台作为服务运行,同时允许用户进行更改并与之交互,比如从它设置的系统托盘图标中调出 UI.截至目前,它确实作为服务成功运行.它执行理想情况下应该执行的所有操作 - 只是没有系统托盘图标来显示 UI 并更改其配置.

Just so that folks here could get a bit more idea as to what is it that I am trying to accomplish - the behavior that I am trying to have with my app is similar to how Dropbox or Yahoo Messenger or any other software has which starts with Windows boot and continues to run in the background, allowing the users to interact with it using the system tray icon. So basically all of this has been built in Java/Swing. Now when it has come to deployment of the app - I can run it standalone but running the jar file or by creating and running an executable wrapper for it. However, I want the software to start with Windows boot and continue to run as a service in the background, while allowing the user to make changes and interact with it via lets say bringing up the UI from a system tray icon that it sets. As of now, it does run as a service successfully. It performs all the actions that it ideally should - there just is no system tray icon to bring up the UI and make changes to its configuration.

更新 - 2

好的..我尝试了高级安装程序,它确实为我打包了所有内容,以便为 Windows 生成一个 exe 安装程序.现在我只需要自动启动软件.谁能帮我这个?我在高级安装程序中没有看到自动让程序在自动启动中添加的选项.

Ok.. I tried advanced installer and it does wrap up everything for me to generate an exe installer for windows. Now all I need is to auto-start the software. Can anyone help me with this? I don't see an option in Advanced installer to automatically have the program add itself up in the auto-start.

链接到 tanuki 的文档 http://wrapper.tanukisoftware.com/doc/english/常见问题.html

Link to tanuki's doc http://wrapper.tanukisoftware.com/doc/english/faq.html

我想评论你的问题,但我没有足够的声誉来做这件事.所以我现在滥用了答案功能.

I wanted to comment on your question, but I don't have enough reputation to do it. So I'm misusing the answer function now.

我也有类似的问题.我在 Windows XP 机器上使用了一段时间的 tanuki 包装器,并且所有登录的用户都看到了 Swing GUI.

I have a similar problem. I used the tanuki wrapper for a while now on a Windows XP machine and the Swing GUI was shown to all users who logged in.

现在我迁移到 Windows 2008 Server 并像这样配置当前版本的 tanuki 包装器:

Now I migrated to Windows 2008 Server and configured the current version of the tanuki wrapper like this:

wrapper.ntservice.interactive=true
wrapper.ntservice.hide_console=true

(请参阅文档此处这里)

Windows 服务在 LOCAL SYSTEM 帐户下运行.

The Windows service runs under the LOCAL SYSTEM account.

但是 GUI 仍然没有显示.您找到问题的解决方案了吗?

But the GUI is still not shown. Did you find any solution to the problem?