将java作为Windows服务运行的简单灵活的方法 [英] Simple and flexible method to run java as a windows service

查看:433
本文介绍了将java作为Windows服务运行的简单灵活的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读SO q& a关于启动java作为Windows服务包装器,但找不到/选择产品,适合我的要求:

I read SO q&a about launch java as windows service wrappers, but can't find/choose product, suitable for my requirements :


  1. Wrapper从配置文件中读取所有java启动参数。在注册表中必须只有命令来运行包装器本身 - exe的路径和可能的配置路径。始终授予管理员权限以更改注册表中的应用参数是不舒服的。

  1. Wrapper reads all java launch parameters from config file. In registry must be only commands to run wrapper itself - path to exe and maybe path to config. Always grant admin rights to change app parameters in registry is not comfortable.

工作目录和应用程序路径也必须在配置中。我想将所有包装器文件深入到程序中,因为用户并不感兴趣。

Working dir and path to application also must be in config. I want to place all wrapper files deep into program, because user not intrested in it.

没有依赖项(.net,python等)。我不想扩展我的程序的要求。

No dependencies(.net, python, etc). I don't want to extend requirements of my program.

每个Windows操作系统都免费,包括win64。

Free for every windows OS, include win64.

简单轻便。所有第三方罐子的程序大小为12Mbytes。我不想添加20Mbytes包装器。

Simple and lightweight. Size of my program with all 3rd party jars is 12Mbytes. I don't want to add 20Mbytes wrapper.

如果应用程序进程终止,则自动重启。

Automaticaly restart if app process dies.

最好是所有Windows平台的单个exe文件。

Preferably single exe files for all windows platform.

我试着通过不同的包装看起来有点累了。最合适的是:

I try and lookinkg throught different wrappers and tired a bit. Best suitable till now is:


  1. jslwin( http://jslwin.sourceforge.net ),但我不知道它有多成熟(版本0.99)。配置中的参数列表也有点复杂(需要编辑参数数量)。

  2. winrun4j( http://winrun4j.sourceforge.net ),但我不知道它有多成熟(版本0.45)。此外,它还需要一个特殊的课程作为服务。

  1. jslwin (http://jslwin.sourceforge.net), but i don't know how mature it is(version 0.99). Also parameter lists in config is a bit complex(need to edit parameters quantity).
  2. winrun4j (http://winrun4j.sourceforge.net), but i don't know how mature it is(version 0.45). Also it needs a special class for working as a service.

我也尝试或查看:


  1. YAJWS( http://yajsw.sourceforge.net/)太大(30mb),无法使其与自定义文件布局一起使用。

  2. 高级安装程序( http://www.advancedinstaller.com )太大(50mb)。

  3. nssm( http://nssm.cc/ )在注册表中存储启动参数(无配置)

  4. winsw( https://kenai.com/projects/winsw ).net必需,在流程终止后停止

  5. commons-daemon,procrun( http://commons.apache.org/proper/ commons-daemon / index.html )在注册表中存储启动参数(无配置),无法理解这个产品,我觉得很复杂。

  6. jsmooth( http://jsmooth.sourceforge。 net )复杂和旧(2007年最后更新)

  7. javaservice( http://forge.ow2.org/projects/javaservice/ )old(2006年最新更新)

  8. runasservice( http://runasservice.sourceforge.net/ )需要.net

  9. windows rktools - sc,instsrv,srvany ( http://support.microsoft.com /?scid = kb%3Ben-us%3B137890& x = 16& y = 7 ) - 在注册表中存储启动参数(无配置)

  10. jwrapper( http://www.jwrapper.com/ )似乎不是我需要的。它使用JRE在exe文件中打包java程序。这不是关于Windows服务的。

  11. firedaemon( http://www.firedaemon.com / )不是免费的。也许这不是我需要的。

  12. launch4j( http://launch4j.sourceforge .net / )很酷的能力搜索或下载java。也许我添加这样的东西来简化安装,但它仍然不是关于subj。

  13. Java服务包装器( http://wrapper.tanukisoftware.com/ )不能免费获得win64。

  1. YAJWS (http://yajsw.sourceforge.net/) too big (30mb), can't make it work with custom files layout.
  2. Advanced Installer (http://www.advancedinstaller.com) too big (50mb).
  3. nssm (http://nssm.cc/) store launch parameters in registry(no config)
  4. winsw (https://kenai.com/projects/winsw) .net required, stops after process dies
  5. commons-daemon, procrun (http://commons.apache.org/proper/commons-daemon/index.html) store launch parameters in registry(no config), can't understand this product, i think it's complex.
  6. jsmooth (http://jsmooth.sourceforge.net) complex and old(last update 2007)
  7. javaservice (http://forge.ow2.org/projects/javaservice/) old (last update 2006)
  8. runasservice (http://runasservice.sourceforge.net/) requires .net
  9. windows rktools - sc, instsrv, srvany (http://support.microsoft.com/?scid=kb%3Ben-us%3B137890&x=16&y=7) - store launch parameters in registry(no config)
  10. jwrapper (http://www.jwrapper.com/) seems not what i need. It packs java program in exe file with JRE. It's not about windows services.
  11. firedaemon (http://www.firedaemon.com/) not free. And maybe it's not what i need.
  12. launch4j (http://launch4j.sourceforge.net/) cool ability "search or download java". Maybe i add something like this to simplify installation, but it is still not about subj.
  13. Java service wrapper (http://wrapper.tanukisoftware.com/) not free for win64.

告诉我请问哪种包装适合我的需求?或者我认为上面的包装有问题,其中一些适合我的需要?

Tell me please which wrappers suits my needs? Or maybe i think wrong about wrappers above and some of them suits my needs to?

推荐答案

多年来我遇到过类似的问题。并不是说它们都是劣等的,它们很难很好地与你自己的项目整合。

I have had similar issues over the years. Its not that they all are inferior, its that they are all pretty hard to integrate nicely with your own project.

你可能想看看鹳: https://github.com/fizzed/stork

它将帮助为您的Java控制台或守护程序应用程序创建启动程序,它们将适用于所有主要平台。还有一个maven插件,以防你想将它绑定到现有的构建过程中。

It'll help create launchers for your Java console or daemon apps, and they will work across all major platforms. There is also a maven plugin in case you wanted to tie it into your existing build process.

这篇关于将java作为Windows服务运行的简单灵活的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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