简体   繁体   中英

How do I make a custom windows service?

Actually I am having one java program. That returns "Hello World". I converted it to jar file. After that I changed the file type as .exe with the use of iexpress in my windows XP default sw.

I used the sc create command, for creating new service. I created the windows service successfully. But the thing is I am not able to run this. It is throwing the following error.

在此输入图像描述

This error is coming not only for this javaservice.

I tried to run the chrome.exe as windows service, That time also it is throwing the same error.

Is it windows constraints? or Am I making mistake? Expecting the solution.,

Thanks in Advance...

You cannot just assign any arbitrary .exe file as-is to run as a service. There are specific API functions involved that services must use to interact with the Service Control Manager (SCM). That is why you are getting the errors - those .exe files are not using those APIs to interact with the SCM.

If you are not writing code specifically for SCM interaction (Java does not support creating Windows services), then all is not lost. In some situations (Chrome NOT being one of them!), you can use a separate wrapper to host non-service apps and handle the SCM interactions on their behalf:

Service wrapper

For Java apps, there are a few wrapper projects available:

Java Service Wrapper

Yet Another Java Service Wrapper

ow2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM