changeset 4648:982484a78b75

nsis-installer: check for java using same tests of octave uses (Bug #53572) * tools/makeinst-script.sh.in: check for RuntimeLib using java 8 & java 9 registry positions
author John Donoghue
date Fri, 06 Apr 2018 16:15:00 -0400
parents 7eebfda7daa1
children b959f5d524f8
files tools/makeinst-script.sh.in
diffstat 1 files changed, 19 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/tools/makeinst-script.sh.in	Thu Apr 05 16:40:33 2018 -0400
+++ b/tools/makeinst-script.sh.in	Fri Apr 06 16:15:00 2018 -0400
@@ -647,22 +647,28 @@
   Push \$R0
   Push \$R1
 
-  ; use javaw.exe to avoid dosbox.
-  ; use java.exe to keep stdout/stderr
-  !define JAVAEXE "javaw.exe"
-
+  # get the version
+  ClearErrors
+  ReadEnvStr \$R1 "JAVA_VERSION"
+  StrCmp \$R1 "" 0 have_java_version
   ClearErrors
-  ReadEnvStr \$R0 "JAVA_HOME"
-  StrCpy \$R0 "\$R0\\bin\\\${JAVAEXE}"
-  IfErrors 0 continue  ;; 1) found it in JAVA_HOME
-
-  ClearErrors
+  ReadRegStr \$R1 HKLM "SOFTWARE\\JavaSoft\\JRE" "CurrentVersion"
+  IfErrors 0 have_java_version
   ReadRegStr \$R1 HKLM "SOFTWARE\\JavaSoft\\Java Runtime Environment" "CurrentVersion"
-  ReadRegStr \$R0 HKLM "SOFTWARE\\JavaSoft\\Java Runtime Environment\\\$R1" "JavaHome"
-  StrCpy \$R0 "\$R0\\bin\\\${JAVAEXE}"
+  IfErrors JRE_Error have_java_version
 
-  IfErrors 0 continue  ;; 2) found it in the registry
-  IfErrors JRE_Error
+ have_java_version:
+  ClearErrors
+  ReadRegStr \$R0 HKLM "SOFTWARE\\JavaSoft\\JRE\\\$R1" "RuntimeLib"
+  IfErrors 0 have_java_runtime
+  ReadRegStr \$R0 HKLM "SOFTWARE\\JavaSoft\\Java Runtime Environment\\\$R1" "RuntimeLib"
+  IfErrors JRE_Error have_java_runtime 
+
+ have_java_runtime:
+  # have runtime in R0 - check actual file is there
+  StrCmp \$R0 "" JRE_Error 0
+  ClearErrors
+  IfFileExists \$R0 continue JRE_Error
 
  JRE_Error:
   MessageBox MB_ICONEXCLAMATION|MB_YESNO "Octave has the capability to call Java libraries, but the installer was unable to find a Java Runtime Environment (JRE) on this system.  Octave will still function without a JRE, only certain specific functions will be disabled.  If a JRE is installed later, Octave should be able to detect and use it automatically.  Continue with installation?" /SD IDYES IDYES continue