Creating a Java Service InstallationLet's say that we want to create a Windows Installer package for the included Java Service example. This tutorial will present in detail how to achieve this goal. In order to replicate it on your own machine, you need to have a (latest) Sun JDK installed. Before you start the tutorial download and unzip the Java Service Example. It contains all the files necessary to accomplish this tutorial.
Prepare a Java application for running as a serviceYou have the choice of using the supplied example application or making your own. In order for a Java application to work correctly as a service you must implement 2 methods in its main class:
public static void main(String argv[])
{
// implementation goes here
}
public static void stop()
{
// implementation goes here
} The main() method will be called when the service starts and the stop() method will be called when service must stop or the computer is shutting down. Create the projectStart Advanced Installer by selecting it from the "Start" menu. Launching Advanced Installer automatically starts a new installation project. Choose "Java Application" as the project type.
Enter the Product Details
Please note that these details are completely fictive. Set the Install Parameters
Add the Installation Files
Define the Java Products
Click on the button and browse to and select the javaservice.jar file. Click Ok. Edit the Main class to: com.caphyon.service.JavaService. At the application type select "Win32 Service".
Now a new file has appeared in the Files and Folders Page: javaservice.exe. Define the Service
Install a new service
Enter service propertiesLeave Service Name unchanged. Edit the Display Name: Java Service Example. Edit the Description: This a Java Service Example. Leave the Service Parameters, Service context and Service Account unchanged.
Setup the control actions
Edit the Service Name to: javaservice.exe. Leave anything else unchanged.
Build
Run, test and removeClick on the toolbar button to run and test the MSI you created. After installation you should have a new service installed. To test the application open console and enter the following command: telnet localhost 4444. You should see:
Java Service is running
Connection to host lostYou also can build Java Service Example msi package using ant. Open a console window and change current directory to the directory where you unzipped the Java Service example archive. Execute the following command: ant msi. To remove the installed package, simply Run it again and select Remove. That's it! | |
|
| Privacy Policy | Windows Installer | Search Engine Ranking | Link Analyzer | ||
| © 2002 - 2008 Caphyon Ltd. Trademarks belong to their respective owners. All rights reserved. | ||