Friday, April 27, 2007

Marrying your Java App to Windows Service

That was the title I had given for my article that got published earlier this week on Devx. The published version is being called Converting Your Java App into a Windows Service. The editor might have felt marriage a bit of an overstatement for a straight forward integration;) Nevertheless I have tried to demystify what I call the unholy marriage. Yet the prerequisite is that the reader is aware of Win32 API, multi-threading, C/C++ and JNI concepts.

5 comments:

Jason Untulis said...

The sample code on devx for DummyService has a pretty fatal flaw. The first line of main(), where it does a check for the number of arguments on the command line does this:

if(argc = 1) {
// blah
}

I will leave the error detection as an exercise for the reader. I hope the rest of the code was at least run...

Naren said...

thanks for pointing it out. I am aware of it. That was the part i added towards the end. I have tested rest of the code thoroughly. Trust me on that. People have noticed and corrected it themselves and used the service effectively.

Tosh said...

I had to modify the code to compile under vs.net 2003. I had to change the printf_s to printf and the fopen_s to fopen. Changing it to fopen made me change the log function to have the line pFile = fopen(LOG_FILE,"a"); Should this still work?

Naren said...

yes tosh it should work.if you still have issues let me know - narenatdooruldotcom

Anonymous said...

I always get the error code 1053 when I try to start the service. I succeeded in installing it.