如果使用一个java的运行程序能象window的系统服务一样,开机总是运行

luozheng 2003-10-15 11:14:30
我这个程序不需要界面,但必需要是一直处于运行状态。如果是window的程序,可以写一个系统服务。但是java是如何实现呢?
...全文
102 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Jimmy.Chiang 2003-10-30
  • 打赏
  • 举报
回复
楼上的看清楚问题没有?
etre 2003-10-15
  • 打赏
  • 举报
回复
加入Windows服务吧

对于NT和Win2k系统如果你要安装NT或Win2k服务的话,请你首先下载JavaService.exe文件,在这里http://www.alexandriasc.com/software/JavaService/JavaService-bin-1.2.0.zip
请解压开
请把下面的这个文件保存为Jboss_Tomcat_Service.bat当然你可以存为其他的名字
@echo off
if "%1" == "uninstall" goto uninstall
if "%1" == "-uninstall" goto uninstall
if "%1" == "" goto usage
if "%2" == "" goto usage
if "%3" == "" goto usage
if "%1" == "-help" goto usage
if "%1" == "-?" goto usage
if "%1" == "/?" goto usage
:install
JavaService.exe -install JBoss30 %1\jre\bin\%3\jvm.dll - Djava.class.path=%1\lib\tools.jar;%2\bin\run.jar -start org.jboss.Main -stop org.jboss.Main -method systemExit -out %2\bin\out.txt -current %2\bin
goto eof
:uninstall
JavaService.exe -uninstall JBoss30
goto eof
:usage
echo -------- To Install JBoss 3.0 do
echo Usage: %0 jdk_home jboss_home (classic/hotspot/server)
echo NOTE: You MAY NOT use spaces in the path names. If you know how echo to fix this, please tell me.
echo JDK 1.3 does not come with hotpot server by default,
you must echo install this seperately if you wish to use it.
echo Example: %0 c:\progra~1\jdk c:\progra~1\jboss30 hotspot
echo --------
echo -------- To Uninstall JBoss 3.0 do
echo Usage: %0 uninstall echo --------
goto eof
:eof
存入和JavaService.exe相同的目录,运行下面的
JBoss30 .c:\jdk1.3.1 f:\Jboss_tomcat server
其中c:\jdk1.3.1是java安装的目录
f:\Jboss_tomcat是Jboss安装的目录
server是不变的参数
你将会看到安装成功的命令,你到win2k或NT的Service中看我可以看Jboss3.0的服务,你可以正常的起动它。
安装就说到这里了,接下面我们再说配置如数据库,邮件,JMS,EJB等等

LoveRose 2003-10-15
  • 打赏
  • 举报
回复
可以写入注册表吧!系统启动就运行该程序

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧