If you use Maven to build your Java applications, read on to learn how to compile them down to optimized native executables by pasting eight lines into your Maven project.
Just in case you came to this post without knowing what Excelsior JET is, let me introduce it briefly. Put simply, Excelsior JET is a tool that can compile your Java application into an optimized native executable for any of the major desktop platforms. Yes, you can fully compile your Java programs down to native code as if they were C++ programs! You might say, why? For a complete answer, look here, I would just like to note that reflection, JNI, dynamic class loading, etc., still work after native compilation, so you do not need to change anything in your Java application prior to using Excelsior JET.
If you are already an Excelsior JET user and also happen to use Maven, then we have some good news for you: we have started developing a Maven plugin for our product, and the first public version (0.1.0) is already available from Maven Central. It supports the bare minimum required for the plugin to be useful in at least some real-world scenarios, but we believe that eventually it will cover all features exposed via the Excelsior JET GUI.
Update 15-Dec-2015: Version 0.2.0 is out with support for Excelsior Installer and Windows version-information resources.
Usage and How it works
By default, the plugin assumes that Excelsior JET is installed and can be found via the
PATH environment variable. If that is the case, you just need to copy and paste the following configuration into the
<plugins> section of your
<plugin> <groupId>com.excelsiorjet</groupId> <artifactId>excelsior-jet-maven-plugin</artifactId> <version>0.1.0</version> <configuration> <mainClass></mainClass> </configuration> </plugin>
and set the
<mainClass> parameter. Issuing the following command will then initiate a native build of your application:
How it works? First, the plugin takes the main artifact of your Maven project, with all dependencies, and compiles all those jars into a native executable. Upon success, it copies that executable and the required Excelsior JET Runtime files into a separate directory that you may just copy to another computer that has neither Excelsior JET nor the Oracle JRE installed. Finally, the plugin packs the contents of that directory into a zip archive. That’s all!
Configurations other than mainClass
First, you may need to tell the plugin where the copy of Excelsior JET that you want it to use is located, especially if you have several versions of Excelsior JET installed on your system (32- and 64-bit, for instance).
You have three ways to specify the Excelsior JET installation directory to the plugin explicitly: the
<jetHome> parameter of its
jet.home system property passed to Maven, or the
JET_HOME environment variable. If none of these is set, the plugin will search for an Excelsior JET installation along the
There are also two useful Windows-specific configuration parameters:
<hideConsole>true</hideConsole> – hide console
</icon> – set executable icon
Update 15-Dec-2015: Version 0.2.0 adds a bunch of configuration parameters pertaining to Excelsior Installer and Windows version-information resources. Refer to the README file for details.
To demonstrate the process and result of plugin usage, I have forked the JavaFX VNC Client project on GitHub, added the Excelsior JET plugin to its
pom.xml file, and run it through Maven to build native binaries for three platforms.
You can download the binaries from here:
or clone my project and build it yourself:
git clone https://github.com/pjBooms/jfxvnc cd jfxvnc/ui mvn jet:build
Funny note: to build the VNC client on Linux and OS X I have used the just compiled jfxvnc for Windows to connect to our Linux and OS X build servers.
Your Feedback Is Needed!
Excelsior JET has many features that this plugin does not support yet, such as our unique Java Runtime Slim-Down technology. It would take quite a lot of time to cover them all in the plugin.
Therefore, we’ve decided to treat the plugin as a micro-startup – release an MVP (minimal valuable prototype) first, and follow up with new versions as quickly as possible, adding more and more new features.
Moreover, we would like to develop the plugin based on your feedback. To facilitate this, we’ve published its source code on GitHub. What does that mean to you?
- First, that means that the plugin is a free open source project (GPLv3).
- Then that means that you are most welcome to create issues on GitHub to request features or report bugs.
- Moreover, you can develop the plugin with us! If you need some functionality that is not covered by the plugin yet, and we are busy with other important features, you can develop that functionality and send us a pull request.
- Finally, you may fork the plugin and customize it to your specific needs without sending pull requests to us.
Even though we are going to base the plugin development on your feedback in the future, we have our own short-term plan as well. So the next few releases will add the following features:
Packaging the natively compiled application with Excelsior Installer for Windows and Linux. Adding version information to Windows executables will also be supported.Update 15-Dec-2015: Available since version 0.2.0.
- Startup time optimizations. These optimizations are only possible in the presence of a startup execution profile, so the plugin will have the ability to gather that profile.
- Java Runtime Slim-Down.
- Mapping of compiler and packager options to plugin configuration parameters.
- Creation of Mac OS X application bundles.
- Code signing.
- Tomcat Web Applications support.
Note that the order of appearance of these features is not fixed and can be adjusted based on your feedback.
What about the other build tools?
Indeed, we would like to enable easy usage of Excelsior JET with other build tools such as ANT, Gradle, or Ivy. Our choice of Maven is based on the ZeroTurnAround 2014 survey. According to the respondents, 64% of their Java projects used Maven as the main build tool. So we have decided to start with Maven and then see if there is a demand from users of other build tools.