[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

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..
0
zicai
Asked:
zicai
  • 3
  • 2
  • 2
  • +2
1 Solution
 
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
 
Ravindra76Commented:
Hi zical,

Visit this

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

Best of luck
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now