0

Amazon Corretto is a replacement to Oracle JRE/JDK.

Is there a way to detect if Corretto is installed (on windows machine) programmatically and if installed - which version ?

Dani
  • 14,639
  • 11
  • 62
  • 110

1 Answers1

1

You can check if the Default installed JDK is Amazon Corretto by checking the JAVA_HOME path, and if it's you can get the version from the path for example

String javaHomePath = System.getProperty("java.home");
if (javaHomePath.contains("corretto")) {
            
}

Or you check if it installed but not default by checking the list of files in the JAVA_HOME parent directory for example

File file = new File(javaHomePath);
File[] jvmFiles = file.getParentFile().listFiles();
for (File jvmFile : jvmFiles) {
    if (jvmFile.getPath().contains("corretto")) {
        String amazonCorrettoPath = jvmFile.getPath();
    }
}
AmrDeveloper
  • 3,826
  • 1
  • 21
  • 30