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

查看:23
本文介绍了如何守护 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天全站免登陆