Get the latest tech news

Compiling Java into native binaries with Graal and Mill


How to Compile Java into Native Binaries with Mill and Graal Li Haoyi, 1 February 2025 One recent development is the ability to compile Java programs into self-contained native binaries. This provides more convenient single-file distributions, faster startup time, and lower memory footprint, at a cost of slower creation time and limitations around reflection and dynamic classloading.

At a glance, the difference between the traditional executable assembly and the Graal native image we built above can be summarized below: The~175ms speedup shown is for a tiny example program, and can be expected to grow for larger Java applications which normally can take multiple seconds to start up. Nevertheless, whether this speedup is significant depends on the use case: for long-lived webservers saving a few seconds on startup may not matter, but for short-lived command line tools this startup overhead may dominate the actual work the program is trying to do, and saving 100s to 1000s of milliseconds with a native binary can be worthwhile.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Java

Java

Photo of Mill

Mill

Photo of graal

graal

Related news:

News photo

Should First-Year Programming Students Be Taught With Python and Java?

News photo

Swc4j: SWC for Java

News photo

Java's SimpleDateFormat: YYYY vs. Yyyy