-4

All of the solutions I found on stackoverflow suggest wrappers to register java application as windows service. My requirement is totally different. Please don't suggest wrappers for the purpose. The question is very simple I have java executable and I want to register it as windows service.

Phyiscal Path

Service Properties

Anwar
  • 1
  • 4
  • What do you call a java executable? Single .class file, or a set of .class files, or a set of packaged .jar files, or a fat jar? Do you mean a .jar file you can call by 'java -jar ...'? Why can't you use a wrapper? – Jorge_B Nov 10 '16 at 10:51
  • If your requirement is different, explain your requirement so the right information can be given to you. – Takarii Nov 10 '16 at 10:52
  • @Jorge our application extension is .exe and it is already installed on other machine as windows service without any wrapper. Installed Service's 'Path to executable:{Physicall Path of java.exe -argument1 argument2}. The service is running absolutely fine on the system. Now I need to install the service on another machine. I also attempted sc.exe but service didn't start after install didn't start in timely fashion. So please suggest me some way how can I properly install the java exe as windows service. – Anwar Nov 10 '16 at 11:03
  • @Takarii requirement is explained above. I have java.exe and it is already running as windows service. Unfortunately we don't have backup of previous setup that installed it as windows service at the first place. Do I need some setup program or anything like that. – Anwar Nov 10 '16 at 11:08
  • 3
    You don't explain your requirement at all, just that it is different to using a wrapper. http://winrun4j.sourceforge.net/ is an alternative to javaw – Takarii Nov 10 '16 at 11:11
  • What has this got to do with Eclipse plugins? – greg-449 Nov 10 '16 at 11:14
  • @Takarii the problem with the wrappers they get installed themselves instead of installing application.exe. Please check the Path to executable: carefully it must be myapplication.exe. – Anwar Nov 10 '16 at 11:15
  • @greg-449 just out of curiosity. Eclipse is used to write java application of all kind and this stunned my no 1 has direct support. It is so easy task in case of Visual Studio. I want same support in Eclipse or anything else. – Anwar Nov 10 '16 at 11:24

1 Answers1

1

Unfortunately we don't have backup of previous setup that installed it as windows service at the first place. Do I need some setup program or anything like that.

Not necessarily.

It is difficult to advise you on precisely what you need to do without more information on what you actually still have; e.g. an application installer, application JAR files, wrapper scripts, etc. Alternatively, if you told us what the application was, then maybe we could give you some hints on where to get installers, etc.

However, I can tell you definitely that registering java.exe or javaw.exe directly as a Windows Service will not work. These are not the executables for your Java application. Rather they executables for as Java Virtual Machine that will run your (real) Java application.

It is so easy task in case of Visual Studio. I want same support in Eclipse or anything else.

Well Java doesn't work like that. Java compiles to platform independent bytecode files, not to platform-specific native code. Sure, there are third party tools to generate exe's. However, using them is neither necessary, or desirable:

(And asking for recommendations on what tools to use to do this is off-topic.)

Finally, if you take an arbitrary Java program and turn it into an ".exe" file, it won't necessarily be immediately registerable as a Windows service. This Q&A talks about turning an ".exe" into a Windows Service.

However, I can't tell you if the advice given there is appropriate for an ".exe" file created from an arbitrary Java app by some unspecified 3rd-part tool.


My recommendation:

  • If you are starting from scratch, use a Java Service Launcher / Wrapper.
  • If not, talk with whoever supplied and/or installed this application in the first place.
  • If you can't find any information about the application and where it came from, or if the vendor has gone out of business ... you need to urgently look for an alternative.
Community
  • 1
  • 1
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • Please check the screen shots.Java exe is installed as windows service. This work is already done on second machine. I just want to do the same on new server now. Any help will be appreciated... – Anwar Nov 10 '16 at 13:46
  • Please correct yourself some tools are available to compile java archive files to .EXE and there are tools available to obfuscate also. – Anwar Nov 12 '16 at 10:37
  • 1) The tools are not recommended. Certainly not for >>this<< context. 2) The OP is in a bind because he had an executable, and thinks he needs to regenerate it. In this case, he probably doesn't need to do that, and he is likely to make life more difficult for himself by taking that approach. (Given that he doesn't know what tool to use, etcetera.) 3) Obfuscation is not relevant to this question. – Stephen C May 29 '17 at 02:33