Topic: 在 Unix 环境下可否将 Java 程序做成类似 daimon(or NT 之 Service)

  Print this page

1.在 Unix 环境下可否将 Java 程序做成类似 daimon(or NT 之 Service) Copy to clipboard
Posted by: 阿熊
Posted on: 2002-11-11 10:28

在 unix 环境下, 可否将 java 程序做成类似 daemon (or NT 之 Service 类)
(能 24hr x 7 days x ...)
目前我的程序功能 ok 了! 但有一个现象:
当我在该 console (于 unix 下) 激活程序如下:
java -classpath ./MDPrj.zip:./classes12.zip md.advance.Collector&
当我关闭此 console 后, 程序亦跟着结束!
即始我用 nohup 指令亦无效!
nohup java -classpath ./MDPrj.zip:./classes12.zip md.advance.Collector&
question:
怎么样我可以让我的程序不随着我关闭 console 而结束?

这种 OS dependence 的功能 Java 是不会支持的, GNU 倒是有个 UNIX Daemon Warpper - djinn 1.1 - Unix daemon wrapper for Java programs , 不妨试试看:
http://www.gnu.org/software/java/java-software.html

2.回复: 在 Unix 环境下可否将 Java 程序做成类似 daimon(or NT 之 Service) [Re: zua] Copy to clipboard
Posted by: lzl
Posted on: 2002-11-12 05:44

Simple way is to make your daemon process a thread, then use Thread.setDaemon(true); before run it.

Event the main() exits, this thread will still be running.

3.回复: 在 Unix 环境下可否将 Java 程序做成类似 daimon(or NT 之 Service) [Re: zua] Copy to clipboard
Posted by: tier3
Posted on: 2002-11-12 09:08

another way is to make the program as a scheduler in the unix system, the best open source scheduler java implementation is Quartz, we are customizing it, it is really a great one.

4.回复: 在 Unix 环境下可否将 Java 程序做成类似 daimon(or NT 之 Service) [Re: zua] Copy to clipboard
Posted by: lzl
Posted on: 2002-11-12 11:10

About Quartz:

We were using Quartz for a while, however, it is not good enough, so we move to Flux (not opensource).

1. Quartz did not implement pause/resume yet

2. Quartz is not qualified to run inside AppServer yet. The author seems has not much idea about AppServer thread management. Basically if you start a new thread in Quartz which is out of the control of AppServer, there is no guarrantee that the synchronization will work correctly.

3. The only way to make scheduler work inside AppServer is JMS, that will relates to lots of work, so why not directly go for Flux.

4. Business Calendar support and Management support in Quartz is very limited.

So, as simple scheduler Quartz is good. It just can not work inside enterprise software yet.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923