Generated Exe Integrate

Integrate java code with binary generated exe


Overview

To integrate with generated exe is not necessary. But if you want to let some of the enhanced functions to work, you need to do a little of integration. Every api to integrate is very simple.

There are some internal System Properties defined if java program runs in generated exe:

  • System.getProperty("j2e.app.path") - The full path of running exe file.
  • System.getProperty("application.home") - The directory where the running exe file is.
  • System.getProperty("j2e.is.elevated") - Since V2.1.6 - Will be "true" if the current process is running as administrator mode.

Download API Library

Before you begin to integrate, download the integrate API:

  • Integrate API - 20K, API library to integrate with generated exe.

Service

Any java program can be converted to Service type of application to run as Service without special integration.

  • If the main() exits without other non-daemon threads running, the Service status is turned into Stopped.
  • If the main() keeps running, e.g. "sleep()", or "accept()", or main() has returned but another non-daemon thread is running, the Service status keeps Running.

While the service keeps running, System Administrator can stop the service by command "net stop ServiceName"(Windows) or "service ServiceName stop"(Linux).

If you want to get the Event of Stop Service, you need to do some integration to set a listener.

  • See Service page for details of service integration.

Protected Resource

If one of the 'protect' options is selected during generating, the protected classes and resources are loaded through a special ClassLoader.

The protected program should run normally, just like it is a jar file executed by 'java' command line.

But sometimes a third-party library may fail to work if it need the protected resources. Usually, to resolve the problem, you can try to select Thread .currentThread .getContextClassLoader() instead of ClassLoader of current class.


Event Log

 This function is supported on Windows only.

If you want to use Event Log function on Windows, you can simply call the reportEvent() method of EventLog class in the integrate API.

  • See Event Log page for details of using Event Log.

System Tray

 This function is supported on Windows only.

If you want to show a System Tray on taskbar, to do integration is required. You need to create a SystemTray instance, call show() method, set a Listener etc.

Because this function is provided by Jar2Exe, the System Tray function will work only when the program is run as generated exe.


Splash Window

 This function is supported on Windows only.

To integrate with Splash Window is not necessary.

If you want to control the Splash Window, for example: to show for a longer time, or close at a certain moment, you need to do some integration

 

Add new comment