如何将 Java 应用程序安装为服务 [英] How to install a Java application as a service

查看:47
本文介绍了如何将 Java 应用程序安装为服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个 Java 应用程序,可以将选定的文件转发到 ssh 服务器.我希望这个应用程序在每次 Windows 启动时自动运行.

I have a Java Application written that forwards selected files to an ssh server. I want this application to be automatically run every time windows starts.

我知道这个问题已经被问过很多次了,我一直在关注这些线索.我尝试过 Java Service Wrapper(由于 dns 问题而无法再访问)、Apache Daemon 和 JSL.虽然我有时能够将应用程序安装为服务,但我一直无法让它在启动时正常运行,甚至无法从命令行手动启动它.

I am aware that this question has been asked multiple times, and I have followed those leads. I have tried Java Service Wrapper (which is no longer accessible because of a dns problem), Apache Daemon, and JSL. Though I have at times been able to get the application installed as a service, I have never been able to get it to run properly on boot, or even start it manually from the command line.

我的问题是是否有人知道如何完成这项工作的完整第一步到最后一步教程.我遇到了一些事情,但他们要么假设你已经实现了一些他们没有解释如何实现的东西,要么依赖于我没有安装的应用程序.

My question is whether anyone is aware of a full first step through final step tutorial of how to make this work. I have come across a few things, but they all either assume that you have implemented something that they do not explain how to implement, or rely on applications that I do not have installed.

谢谢

推荐答案

我使用 Java Service Wrapper 安装为 windows 或 linux 服务:http://wrapper.tanukisoftware.com/doc/english/download.jsp

I use Java Service Wrapper to install as windows or linux service: http://wrapper.tanukisoftware.com/doc/english/download.jsp

~> 为您的应用创建一个可运行的 JAR.

~> create one runnable JAR to your app.

~> 下载适当的服务包装器(它们与 windows 和 linux 不同)

~> Download the proper service wrapper (they are diffrent to windows and linux)

~> 在 wrapper.conf 中配置服务

~> Configure the service in wrapper.conf

重要:设置 wrapper.java.classpath 正确(你的 jar 也必须在这里)使用 org.tanukisoftware.wrapper.WrapperSimpleApp
设置 wrapper.java.mainclasswrapper.app.parameter.1 设置为您的主类的名称,例如:

Important: set wrapper.java.classpath correct (your jar must be here too) Set wrapper.java.mainclass with org.tanukisoftware.wrapper.WrapperSimpleApp
Set wrapper.app.parameter.1 with the name of your main class, for example:

wrapper.app.parameter.1=Main

~> 作为控制台测试服务(windows bat)

~> Test the service as console (windows bat)

这篇关于如何将 Java 应用程序安装为服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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