Get the latest tech news

How Java's Executable Assembly Jars Work


VM Executable Assembly Jars Work Li Haoyi, 2 January 2024 One feature of the Mill JVM build tool is that the assembly jars it creates are directly executable: > ./mill show foo.assembly # generate the assembly jar "ref:v0:bd2c6c70:/Users/lihaoyi/test/out/foo/assembly.dest/out.jar" > out/foo/assembly.dest/out.jar # run the assembly jar directly Hello World Other JVM build tools also can generate assemblies, but most need you to run them via java -jar or java -cp, or require you to use jlink or jpackage which are much more heavyweight and troublesome to set up. Mill automates that, and while not groundbreaking, it is a nice convenience that makes your JVM code built with Mill fit more nicely into command-line centric workflows common in modern software systems.

What makes an assembly different from a "normal" jar is that it should (in theory) contain everything needed to run you JVM program. You can see that from the command line, where although you normally use jar tf to list the contents of a.jar file, unzip -l works as well: Larger projects will have multiple class files, including those from upstream modules and third-party dependencies.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Java

Java

Related news:

News photo

So you want to write Java in Neovim

News photo

Mixin is a trait/mixin and bytecode weaving framework for Java using ASM

News photo

Translating 10M lines of Java to Kotlin