Java Service Wrapper Tutorial

Active6 years, 6 months ago

YAJSW is a java centric implementation of the java service wrapper by tanuki (JSW). It aims at being mostly configuration compliant with the original. It should therefore be easy to. The usual Java Hello World application starts up, prints out Hello World and then exits. That is not very interesting to show off a tool for running and monitoring services. In the case of the Java Service Wrapper, an example which can be installed and then stay running as a Windows Service, or UNIX daemon is required.

I have simply donwloaded JSW community edition, unwrapped into a directory:
c:servicetest
So here i have a bin, conf, lib and log subdirs, among others.From now on this will be (root).
I referenced the (root)/lib/wrapper.jar into my ide (netbeans) and create a very simple service (remember the class name is Main):

As you see, it basically does nothing but logging a message. But actually it neither starts.

I compiled the project (MyProject.jar), copied the jar into the (root) directory and modified the (root)/config/wrapper.conf adding:

and

Java service wrapper tutorial template

Then i've installed the service in command line, with:

then i've started the service, either via services.msc control panel or via

In logs/wrapper.log i get:

Java Wrapper Example

UPDATE 1

Following Tanuki Software advice, i've set in my (root)/config/wrapper.conf (well, uncommented since it already was):

Jabber for windows software download. Cisco Jabber for Windows Collaborate anytime, anywhere Streamline communications and enhance productivity by integrating presence, instant messaging, desktop sharing, and audio, video, and web conferencing into a single client for your laptop or desktop. When autocomplete results are available use up and down arrows to review and enter to select. JabberIM is a full-featured consumer and business instant messaging client for Windows. JabberIM is one of several Windows clients that are compatible with the Jabber technology. With Cisco Jabber 12.7 we’ve created a contemporary new look for Jabber, giving your users a modern experience that they expect from their enterprise applications. Watch video (1.56) Download software; Capabilities and benefits. Explore the key features to Cisco Jabber. Cisco Jabber Team Messaging Mode. Cisco Jabber Call Experience.

And now i get this:

But given my very simple implementation, i cannot guess what is going wrong.

AgostinoX
AgostinoXAgostinoX
3,74317 gold badges65 silver badges111 bronze badges

1 Answer

rather than extending WrapperSimpleApp, your main class should implement the org.tanukisoftware.wrapper.WrapperListener interface.

You can find a very detailed description about implementing the interface on our website:http://wrapper.tanukisoftware.com/doc/english/integrate-listener.html

Please let me know if you have any further questions about the implementation and/or the configuration properties in your conf file.

Another advise which comes in handy for me sometimes, is rather than running your application immediately as service, I find it easier to do the integration by running first as console application, because you can see the output directly on your console. Once everything seems working, I go ahead and install/run as service. To run as console application, you would run for example:

You can also turn on debug output for the Wrapper by setting

in your conf file.

Java Service Wrapper Tutorial Online

Edit due to the comment:

if your application is actually as simple as you describe, then just write your application as normal Java application without any Wrapper API parts.

You can use the WrapperSimpleApp to run your application out of the box with codeless integration into the Wrapper.

All you need to do is set the following properties in your conf file:

With this configuration, the Wrapper will be able to run your application as windows service.

UPDATE2

I'm not sure what your code exactly looks like, but it seems you are calling WrapperManager.stop() in your main class..

Java Wrapper Classes Tutorial

Following the initial example class, I have modified the class, so it is not using any Wrapper-API (which for an simple application is not necessary):

After compile and creating the jar, the necessary properties in the conf file are:

cheers,

NaytzyrhcNaytzyrhc

Not the answer you're looking for? Browse other questions tagged javajava-service-wrapper or ask your own question.