如何守护Java程序? [英] How to Daemonize a Java Program?

查看:92
本文介绍了如何守护Java程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java程序,我想在Linux系统上守护进程。换句话说,我想开始在shell中运行它,并在我退出后继续运行它。我也希望能够干净地停止这个程序。

I have a Java program that I'd like to daemonize on a linux system. In other words, I want to start running it in a shell and have it continue running after I've logged out. I also want to be able to stop the program cleanly.

我找到了本文使用shell脚本和Java代码的组合来完成这一操作。它看起来不错,但如果可能的话,我想要更简单的东西。

I found this article which uses a combination of shell scripting and Java code to do the trick. It looks good, but I'd like something simpler, if possible.

在Linux系统上守护Java程序的首选方法是什么?

What's your preferred method to daemonize a Java program on a Linux system?

推荐答案

Apache Commons Daemon 将您的Java程序作为Linux守护程序或WinNT服务运行。

Apache Commons Daemon will run your Java program as Linux daemon or WinNT Service.

这篇关于如何守护Java程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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