简体   繁体   English

将Java应用程序作为服务运行

[英]Run Java application as a service

I would like to run a Java application as a service. 我想将Java应用程序作为服务运行。 Unfortunately, I am limited in that I can't use something like the Java Service Wrapper (which does appear to be an excellent tool). 不幸的是,我受限制的是我不能使用像Java Service Wrapper这样的东西(看起来确实是一个很好的工具)。

Is there any way of running an executable JAR, as a service, without relying on external applications? 有没有办法在不依赖外部应用程序的情况下将可执行JAR作为服务运行? I currently have the service installed, but it fails to start. 我目前已安装该服务,但无法启动。 This is where I am getting stuck and I haven't been able to find anything on Google other than information about the JSW. 这是我遇到困难的地方,除了有关JSW的信息之外,我无法在谷歌上找到任何东西。

There's an LGPL clone of the Java Service Wrapper: http://yajsw.sourceforge.net 有一个Java Service Wrapper的LGPL克隆:http: //yajsw.sourceforge.net

BTW, IANAL, but I suspect that JSW people are spreading FUD, and their software can be used to service-enable commercial applications under GPL license, just like one can gzip a commercial app for redistribution. BTW,IANAL,但我怀疑JSW人员正在传播FUD,他们的软件可用于在GPL许可下为商业应用程序提供服务,就像人们可以通过gzip商业应用程序进行再分发一样。 I could be completely wrong about this, though :) 我可能完全错了,但:)

Another option, Apache Commons Daemon's procrun. 另一种选择,Apache Commons Daemon的procrun。

See http://commons.apache.org/daemon/ http://commons.apache.org/daemon/

A program that should run as windows service must provide certain functions that the windows service manager uses to communicate with that service. 应作为Windows服务运行的程序必须提供Windows服务管理器用于与该服务通信的某些功能。

As long as there is no JVM that implements this functions directly (and I know of none) you will need some kind of wrapper. 只要没有直接实现此功能的JVM(我也不知道),您将需要某种包装器。

I have successfully used srvany for a java based windows service (Basically it allows to run any program as windows service and it works fine with java) 我已经成功地将srvany用于基于java的Windows服务(基本上它允许运行任何程序作为Windows服务,它可以正常使用java)

我还没试过,但是Launch4j看起来可以满足你的需求。

one more option winrun4j . 还有一个选项winrun4j the license is eclipse's CPL. 许可证是eclipse的CPL。

您可以像这样使用NSSM

nssm install MyService "%JAVA_HOME%\bin\java.exe" -jar "path\to\the\file.jar"

The most simple way I found was RunAsService . 我找到的最简单的方法是RunAsService

A co-worker recommended a tool called SC , but I did not try it. 一位同事推荐了一款名为SC的工具,但我没有尝试过。

JSmooth可以做到这一点,它可以用ant编写脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Linux 上运行 Java 应用程序即服务 - Run a Java Application as a Service on Linux 创建 Java 应用程序以作为 Windows 服务运行 - Create Java Application to run as a Windows Service 在Windows上运行Java独立应用程序(作为服务) - Run a Java standalone application on Windows (as a service) 无法将Java应用程序作为Windows服务运行 - Unable to run a java application as windows service 如何使Java应用程序作为在特定时间自动打开的服务运行 - How to make the java application run as service that opens automatically at particular time Java网络应用程序作为服务丢失网络连接运行 - Java network application run as service losing network connection 以编程方式重新启动可以作为Windows服务运行的Java应用程序 - Programmatically restart a Java application that can be run as a windows service 如何使用WinRun4J将Java应用程序作为Windows服务运行 - How to run a Java application as Windows service using WinRun4J 如何创建一个可以作为窗口服务运行的Java应用程序? - How to create a java application which can be run as window service? 应用程序错误 Azure App Service trying to run Java/Springboot jar - Application error on Azure App Service trying to run Java/Springboot jar
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM