Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Converting Your Java App into a Windows Service

Reusing a framework usually is a good idea, but sometimes developing your own code for a specific task is easier. Developing code to convert a Java application into a Windows service turns out to be one of those rare cases.

ou probably are reading this article because you want to convert a Java application into a Windows service. I can relate. Recently, I wanted to turn a Java server application that embedded the Jetty web server and ActiveMQ JMS client into a Windows service, enabling users to start it automatically without logging into the system. Further, I wanted it to start and stop in a controlled fashion. After searching SourceForge for a suitable project to help me fulfill these specific requirements and coming up empty, I decided to write a simple customized solution of my own.

I discovered you can use one of two approaches to convert a Java application into a Windows service:

  1. The Windows service launches your Java application in a separate process. (The service has no control over the Java application.)
  2. The Windows service creates a Java virtual machine (JVM) in its own process context and then shuts it down in a controlled manner.

I chose the second approach because it delivered everything I needed. This article describes how to apply this approach when you convert your Java application into a Windows service. It walks you through the development steps while highlighting the core concepts. To follow along, you need to have a good understanding of Windows concepts and the Java Native Interface (JNI) invocation API.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date