# HG changeset patch # User Markus Mützel # Date 1522423387 -7200 # Node ID d61f42a392b71faa391fcadc0fd87d1d377d5394 # Parent a038cbe3e6e1047115dae4d41f614dfb0c5344da Find install location of JRE >= 9 on Windows (bug #53520). * ov-java.cc: Use new registry key to search for the Java Runtime library >= 9. diff -r a038cbe3e6e1 -r d61f42a392b7 libinterp/octave-value/ov-java.cc --- a/libinterp/octave-value/ov-java.cc Fri Apr 06 13:33:02 2018 -0400 +++ b/libinterp/octave-value/ov-java.cc Fri Mar 30 17:23:07 2018 +0200 @@ -547,33 +547,49 @@ if (! create_vm || ! get_vm) { #if defined (OCTAVE_USE_WINDOWS_API) - // In windows, find the location of the JRE from the registry + // In Windows, find the location of the JRE from the registry // and load the symbol from the dll. - std::string key, value; - - key = R"(software\javasoft\java runtime environment)"; - - value = octave::sys::env::getenv ("JAVA_VERSION"); + std::string key, jversion, value; + + // First search for JRE >= 9 + key = R"(software\javasoft\jre)"; + + jversion = octave::sys::env::getenv ("JAVA_VERSION"); octave_value regval; LONG retval; - if (value.empty ()) + if (jversion.empty ()) { value = "CurrentVersion"; retval = get_regkey_value (HKEY_LOCAL_MACHINE, key, value, regval); if (retval != ERROR_SUCCESS) + { + // Search for JRE < 9 + key = R"(software\javasoft\java runtime environment)"; + retval = get_regkey_value (HKEY_LOCAL_MACHINE, key, value, + regval); + } + + if (retval != ERROR_SUCCESS) error ("unable to find Java Runtime Environment: %s::%s", key.c_str (), value.c_str ()); - value = regval.xstring_value ( + jversion = regval.xstring_value ( "initialize_jvm: registry value \"%s\" at \"%s\" must be a string", value.c_str (), key.c_str ()); } - key = key + '\\' + value; + key = key + '\\' + jversion; value = "RuntimeLib"; retval = get_regkey_value (HKEY_LOCAL_MACHINE, key, value, regval); if (retval != ERROR_SUCCESS) + { + // Search for JRE < 9 + key = R"(software\javasoft\java runtime environment\)" + jversion; + retval = get_regkey_value (HKEY_LOCAL_MACHINE, key, value, regval); + } + + if (retval != ERROR_SUCCESS) error ("unable to find Java Runtime Environment: %s::%s", key.c_str (), value.c_str ());