Micronaut CLI - The JVM Version

A few weeks ago, when I was checking for the versions of a tool on SDKMAN CLI, I noticed the broadcast message that a Micronaut 2 is available. If you are not familiar with SDKMAN already, you may want to take a look at my post on SDKMAN

I installed Micronaut 2 and invoked the CLI command mn -Version. I got the following output.

➜  ~ mn -Version
Micronaut Version: 2.0.0
JVM Version: 1.8.0_252

Though I got the expected Micronaut version (2.0.0), The JVM version displayed got me suspicious. I thought I had Java 11 default on my system. To validate my assumption, I ran the java -version command, and indeed Java 11 was the default version on my system.

➜  ~ java -version
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)

At this point, I wasn't sure why Micronaut CLI was showing a Java version, which I didn't even have on my system! At this point, I decided to verify how the earlier version of Micronaut behaved. I tried the following commands.

➜  ~ sdk use micronaut 1.3.6

Using micronaut version 1.3.6 in this shell.
➜  ~ mn -Version
| Micronaut Version: 1.3.6
| JVM Version: 11.0.7

Now I was sure something had changed in Micronaut 2. I took a quick glance at the directory structure of Micrnaut 2 and Micronaut 1.3.6

Micronaut 2.0

➜  2.0.0 tree
└── bin
    └── mn

1 directory, 2 files

Micronaut 1.3.6

➜  1.3.6 tree
├── bin
│   ├── mn
│   ├── mn.bat
│   └── mn_completion
├── cli-1.3.6.jar
└── media
    └── mn.icns

2 directories, 6 files

You could see that earlier command mn was just a shell script which was invoking the java application from 'cli-1.3.6.jar'. However, you don't have the jar and shell scripts anymore, and 'mn' is indeed a native binary.

Since Micronaut supported GraalVM from the very beginning, it didn't take further time to realise what is happening here. The Java version displayed earlier was used to compile the CLI application, and then converted into a native executable.

Show Comments