How to create a windows service from java app

前端 未结 19 1922
既然无缘
既然无缘 2020-11-22 04:09

I\'ve just inherited a java application that needs to be installed as a service on XP and vista. It\'s been about 8 years since I\'ve used windows in any form and I\'ve neve

相关标签:
19条回答
  • 2020-11-22 04:48

    it's simple as you have to put shortcut in

    Windows 7 C:\users\All Users\Start Menu\Programs\Startup(Admin) or User home directory(%userProfile%)

    Windows 10 : In Run shell:startup

    in it's property -> shortcut -> target - > java.exe -jar D:\..\runJar.jar

    NOTE: This will run only after you login


    With Admin Right

    sc create serviceName binpath= "java.exe -jar D:\..\runJar.jar" Will create windows service

    if you get timeout use cmd /c D:\JAVA7~1\jdk1.7.0_51\bin\java.exe -jar d:\jenkins\jenkins.war but even with this you'll get timeout but in background java.exe will be started. Check in task manager

    NOTE: This will run at windows logon start-up(before sign-in, Based on service 'Startup Type')

    Detailed explanation of creating windows service

    0 讨论(0)
  • 2020-11-22 04:48

    Exe4j is a very good option although it is not free. Check it out at Exe4j In the wizard to create the .exe file, you are give the option to create a service.

    0 讨论(0)
  • 2020-11-22 04:49

    A simple way is the NSSM Wrapper Wrapper (see my blog entry).

    0 讨论(0)
  • 2020-11-22 04:52

    I think the Java Service Wrapper works well. Note that there are three ways to integrate your application. It sounds like option 1 will work best for you given that you don't want to change the code. The configuration file can get a little crazy, but just remember that (for option 1) the program you're starting and for which you'll be specifying arguments, is their helper program, which will then start your program. They have an example configuration file for this.

    0 讨论(0)
  • 2020-11-22 04:52

    Use "winsw" which was written for Glassfish v3 but works well with Java programs in general.

    Require .NET runtime installed.

    0 讨论(0)
  • 2020-11-22 04:53

    Another good option is FireDaemon. It's used by some big shops like NASA, IBM, etc; see their web site for a full list.

    0 讨论(0)
提交回复
热议问题