How to write NT services?

Hi! Can anyone tell me how to write a Windows NT service using Java? I recently found some material from Microsoft, which says we can use MS SDK for Java to write NT services. I found the sample provided by SDK contains many things that I don't know(and don't understand...). Any good books or good online resources available around now? Anyone have the real experience with writing NT services using Java?

Thank you!
Yours sincerely
Zicai - Interesting, but never be simple..
LVL 2
zicaiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

memingCommented:
Interested in using the following package to setup the service for you by using your java application directly? You won't need to learn any MS programming tricks, nor modify your java program. It opens a console window for the process which can't be closed, but the windows won't be closed when you logoff/logon. Once setup, you can manage the service in control panel the same way as any other services. Multiple services can be given different names. Yes, you can uninstall it too.

http://www.basta.com/ProdAppToService.htm
0
vladi21Commented:
Inherit com.ms.Service from Mirosoft SDK for Java 3.x
Use utilite jntsvc to make .exe and debug in console mode.
System.out/System.err automaticaly redirected to application events log

also look
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=10144087 

You can find a free NT-service wrapper program at
http://innovation.idetix.com/invoker/ 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ravindra76Commented:
Hi zical,

Visit this

http://sunsite.auc.dk/javarc/code/misc/Server/

Best of luck
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

zicaiAuthor Commented:
Hi, everyone!

I tried all the method you provided, but failed with the exception:
java.sql.SQLException: [Microsoft][ODBC Access 97 ODBC driver Driver]General error Unable to open registry key 'DriverId'.
I searched Microsoft's site for the error, but I don't quite understand it.(Search "Unable to open registry key 'DriverId'"). Later I tried to use registry tool: regmon.exe to see what's wrong with the registy. But the result is too difficult for me to understand..
1413      6.83021618      SERVICES.EXE      QueryValue      HKLM\System\CurrentControlSet\Services\TestService\Tag      NOTFOUND
1416      6.83037961      SERVICES.EXE      QueryValue      HKLM\System\CurrentControlSet\Services\TestService\Group      NOTFOUND
1470      10.49179337      SERVICES.EXE      QueryValue      HKLM\System\ControlSet002\Services\TestService\PlugPlayServiceType      NOTFOUND

I tried to use console mode to debug the application, but everything run just fine. What I mean is to use TestService /CMD .... to load the service. That problem only happens when I use the service applet to start the service. Can any experts here help me about this problem? If you need to know more details, pls do let me know. This project is quite important to me..
By the way, I am using JDBC-ODBC bridge within the service.

Thank you very much!
0
mbormannCommented:
zicai,

it looks like vladi21 has got the answer ,have u tried out his thing?
I haven't tried it out ,but will be able to do so only nexct week or so.

post the sample code to me at amit@eparle.com and anything else so that I can compile that and test it etc...

we can discuss this back and forth over here or via EMail.I check mails every 15 mins or so.

this is a no limit company account so feel free to post it here and I will try to steal some time off on Saturday or Sunday (no holiday this week or the next... sigh.)

i was seeing this
http://www.microsoft.com/java/sdk/40/start.htm?http://www.microsoft.com/Java/sdk/40/samples/com_samp.htm
0
vladi21Commented:
maybe u can submit answer for ur initial question
and most more specific question?
0
zicaiAuthor Commented:
Hi, everyone!

I tried all the method you provided, but failed with the exception:
java.sql.SQLException: [Microsoft][ODBC Access 97 ODBC driver Driver]General error Unable to open registry key 'DriverId'.
I searched Microsoft's site for the error, but I don't quite understand it.(Search "Unable to open registry key 'DriverId'"). Later I tried to use registry tool: regmon.exe to see what's wrong with the registy. But the result is too difficult for me to understand..
1413      6.83021618      SERVICES.EXE      QueryValue      HKLM\System\CurrentControlSet\Services\TestService\Tag      NOTFOUND
1416      6.83037961      SERVICES.EXE      QueryValue      HKLM\System\CurrentControlSet\Services\TestService\Group      NOTFOUND
1470      10.49179337      SERVICES.EXE      QueryValue      HKLM\System\ControlSet002\Services\TestService\PlugPlayServiceType      NOTFOUND

I tried to use console mode to debug the application, but everything run just fine. What I mean is to use TestService /CMD .... to load the service. That problem only happens when I use the service applet to start the service. Can any experts here help me about this problem? If you need to know more details, pls do let me know. This project is quite important to me..
By the way, I am using JDBC-ODBC bridge within the service.

Thank you very much!
0
mbormannCommented:
vladi,
this question is still open as zicai has not found answer to question.

>>>>>that problem only happens when I use the service applet to start the service.

what is this ,a Java Applet? if so ,convert it to a Java application with the same GUI ,is this possible ,or have you already signed the applet?

post your relevant code saying where exactly error occurs.That is the only way to solve ur problem.
0
zicaiAuthor Commented:
Hi, all

I accepted vladi21's comment as answer, but it does not mean the rest of you didn't help. All the comments you posted here are very helpful, though finally I used vladi21's method. For the SQL Exception problem, I've solved it:set the service to run under an account that has internet access.

To mbormann: Service applet is an applet in the control pannel. It's not a Java applet:) It's used for windows NT to control system services.

Thank you all, vladi21, ravindra76, meming and mbormann!

Yours sincerely
Zicai - Yeah!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.