How to...

Glue42 Enable Your App



The Glue42 Java library provides an easy way to make your enterprise Java applications Glue42 enabled. You can use the Glue42 Java library in the same way as any standard Java library.

Glue42 Java requires JDK 8+ (Java SE 8+) and is JDK 9+ ready.


<?xml version="1.0" encoding="utf-8"?>
<project xmlns=""





apply plugin: 'java'

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile 'com.tick42.glue:tick42-glue-shaded:1.3.8.RELEASE'

Referencing and Initialization

To use Glue42 Java in your applications, you need add the Glue42 Java library and its dependencies to your application classpath, import the Glue class and create a Glue instance:

import com.tick42.glue.Glue; 

try (Glue glue = Glue.builder().build()) 

In the example above:

  • First, import the Glue42 package.

  • Glue is the main entry point of the SDK. It is thread-safe and you should create a single instance (per Glue42 application) and share it throughout your code.

  • Get the Glue42 version as a string.

Always close the Glue instance once you are done with it, in order to free up underlying resources (ws connections, thread pools, etc.). This example uses a try-with-resources block, because Glue extends AutoCloseable - in a real application, you will probably call close() or closeAsync() explicitly.

Application Shutdown

When initializing Glue42, you can pass an event listener that will notify your application when it is about to be stopped. This is useful when your app/process is not started directly by Glue42, but rather by Glue42 invoking a script/batch file or another application that in turn starts your application. With this listener you can properly shut down your application, free resources, etc.

Below is an example of passing a shutdown request listener when initializing Glue42:

        .withShutdownRequestListener(glue -> {
            System.out.println("Starting shutdown procedure...");


To configure Glue42 Java in your application, you can use .conf, .properties, .json files and system properties to externalize your configuration. For example, if you want to specify a name for your application, you can do so in a glue.conf file:

glue {
    application: "My Java App"

Glue42 Java will look for a Glue42 configuration file in the application classpath. If you are using Maven or Gradle as a build tool, you can place the glue.conf file for your application in the \src\main\resources folder of your project directory.

If you do not specify an application name in a glue.conf file, as in the example above, the name of the application will be taken from the Glue42 Enterprise starting context which contains configurations from the application definition file (see below).

You can also set the application name runtime when initializing the Glue42 Java library, which will override any previous configurations:

Glue.builder().withApplicationName("My Java App").build();

Application Definition

To add your Java application to the Glue42 Enterprise App Manager application, you need to define a configuration file and add it to the application config store. You can add the configuration file for your application in the %LocalAppData%\Tick42\UserData\<ENV-REG>\apps folder to publish your own application locally. <ENV-REG> in the link should be replaced with the region and environment folder name used for the deployment of your Glue42 Enterprise - e.g., T42-DEMO. This way, your files will not be erased or overwritten, in case you decide to upgrade or change your Glue42 Enterprise version.

Here is an example:

    "title": "Java Example",
    "type": "exe", 
    "name": "java-example",
    "icon": "",
    "details": {
      "path": "", 
      "command": "java", 
      "parameters": " -jar example.jar", 
      "mode": "tab"
  • type should be exe;
  • path is the path to the application - relative or absolute;
  • command is the actual command to execute (java);
  • parameters holds command line arguments;

Note that the definition should be a valid .json file (you should either use forward slash or escape the backslash).

To be able to start Glue42 Java on a dual core machine, you have to pass the parameter to the JVM by adding it to the parameters property described above.

For more detailed information about the application definitions, see the Configuration documentation.

You can also check out our Java examples at GitHub, demonstrating the various Glue42 Enterprise features.

Glue42 Java Concepts

Once you have created a Glue instance, your application has access to all Glue42 functionalities. For more detailed information on the different Glue42 concepts and APIs, see: