Mercurial > jwe > octave
changeset 25139:d61f42a392b7 stable
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.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Fri, 30 Mar 2018 17:23:07 +0200 |
parents | a038cbe3e6e1 |
children | ad6dce96cbca |
files | libinterp/octave-value/ov-java.cc |
diffstat | 1 files changed, 25 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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 ());