GraalVM is pretty awesome for a lot of reasons. But the one that has me most hyped is the ability to create native executables from Java bytecode. This isn't like ExcelsiorJET (R.I.P.), which makes you include a large runtime, nor is it like Launch4J and Oracle's
javapackager tool, both of which create a dummy executables that points to your
.jar and a packaged JRE.
GraalVM makes real native executables without a packaged runtime.
native-image, and indeed its entire support for Windows, is in early adopter status. There are some error messages that aren't accurate, some bugs, and some features missing.
But it does work, more-or-less.
There's about a 8.5 MB minimum file size for a bare bones
hello world java application. That's kind of a lot, but also a lot less than including the entire JRE.
All the Swing and JavaFX applications I've tried haven't been able to build in the Windows version of
native-image in 19.0.0.
The Image Generation Options page is a good resource for troubleshooting, you may have to place some of your classes into the
--initialize-at-run-time=<comma separated list of class/package names> option.
- Uninstall any
Visual C++ 2010 Redistributables
- Get the Windows version of GraalVM 19.0.0: https://github.com/oracle/graal/releases/tag/vm-19.0.0
- Extract it somewhere easy to find
- Get the Microsoft Windows SDK for Windows 7 and .NET Framework 4 (ISO): https://www.microsoft.com/en-us/download/details.aspx?id=8442
- Mount the image, open
- A default install should be perfect
Run the Windows SDK 7.1 Command Prompt by going to
Microsoft Windows SDK v7.1>
Windows SDK 7.1 Command Prompt
- Run one of these commands based on if you have a
\path\to\graalvm-ce-19.0.0\bin\native-image -jar \path\to\helloworld.jar --no-fallback
\path\to\graalvm-ce-19.0.0\bin\native-image \path\to\helloworld.class --no-fallback
*.pdb files seem to be artifacts of the build process, they're not required for distribution.
But that's it, your
.exe is made!