Method to check if GraalVM JDK Distribution

Method to check if you are running in GraalVM JDK distribution. I have used it often in Gradle build files to decide whether a Gradle task should be enabled.

private static boolean isGraalVMJava() {
        (System.getProperty("java.home") != null && java.nio.file.Files.exists(java.nio.file.Paths.get("${System.getProperty("java.home")}/lib/graalvm")))
        || Arrays.asList("jvmci.Compiler", "java.vendor.version", "java.vendor")
            .anyMatch(propertyName -> {
                String value = System.getProperty(propertyName);
                return value != null && value.toLowerCase(Locale.ENGLISH).contains("graal");

Tags: #java #graalvm #gradle
Sep 2023, 21.


My next events:
🗓 Apr 04 16:30 JDevSummitIL Getting Started with the Micronaut Framework