server

It is possible to run the Java Service Wrapper as an external tool to test your application from Eclipse. This saves you from switching windows each time you want to launch your application with the Wrapper.

We will walk you through a step by step procedure using a simple example to show you how to run the Java Service Wrapper within Eclipse.

Solution

First, you will need a copy of the Java Service Wrapper. Please download it from our download page and extract the files to a convenient location. For this example, we will extract the files and save them in this location: /home/myuser/wrapper.

NOTE

Make sure to have a valid license key.

Technical Overview

In Eclipse, create a sample project called MyApplication. Add a class my.app.test.MyApplication which will simply output "Hello World" to the console.

MyApplication.java
package my.app.test;
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}

External Tools

Here are the steps to setup the External Tools in Eclipse.

  • Click on the arrow next to the icon External Tools.
  • Select External Tools Configurations.
  • Click on Program.
  • Continue and click on the icon New Launch Configuration.
  • We will use Wrapper as the name of the New Configuration.
  • Enter the path to the Wrapper binary file: /home/myuser/wrapper/bin/wrapper
  • In Arguments, enter the following text:
-c ../conf/wrapper.conf 
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp 
wrapper.app.parameter.1=my.app.test.HelloWorld 
wrapper.java.classpath.3=/home/myuser/workspace/MyApplication/bin

Now you should see in the console of Eclipse the output from the Wrapper and of course the following line:

wrapper  | --> Wrapper Started as Console
...
jvm 1    | Hello World