Skip to content
⌘ NSIS Forum Archive

Trouble checking JRE in installer

4 posts

cstokes#

Trouble checking JRE in installer

I've made an installer that makes use of the JRE checking script available here:


When I use this script, my installer produces the error "No Java Runtime Environment could be found on your computer" even though I have Java 1.8 installed. If I understand the logic of this script correctly, this should occur if my Java registry keys aren't set.

I've checked my registry keys, and the following are set:

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment: CurrentVersion = 1.8
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.8: JavaHome = C:\Program Files\Java\jre1.8.0_40

I don't understand why I'm seeing the "No Java Runtime Environment" error - does anyone have any insight?
Anders#
64-bit version of Windows?

64-bit version of Java (does that even exist)?

Are you using SetRegView in your script?
Theresias#
I ran into the same issue but didn't have time to actually check what caused it, instead a simple workaround did the trick for now...


!define JAVA_JRE_REGPATH  "SOFTWARE\JavaSoft\Java Runtime Environment"
!define JAVA_JRE_REGPATH2 "SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment"
!define JAVA_JDK_REGPATH "SOFTWARE\JavaSoft\Java Development Kit"
!define JAVA_JDK_REGPATH2 "SOFTWARE\Wow6432Node\JavaSoft\Java Development Kit"
!define JAVA_DOWNLOAD_URL "http://www.java.com/download"


   # Java Version/Installation Check
SetRegView 32 # Make sure we're checking x86 Registry
!ifdef DEBUG
StrCpy $RegPlatform "x86"
!endif
ReadRegStr $R0 HKLM "${JAVA_JRE_REGPATH}" "CurrentVersion"
IfErrors 0 JavaCheckDone
ReadRegStr $R0 HKLM "${JAVA_JDK_REGPATH}" "CurrentVersion"
IfErrors 0 JavaCheckDone
ReadRegStr $R0 HKLM "${JAVA_JRE_REGPATH2}" "CurrentVersion"
IfErrors 0 JavaCheckDone
ReadRegStr $R0 HKLM "${JAVA_JDK_REGPATH2}" "CurrentVersion"
IfErrors 0 JavaCheckDone

SetRegView 64 # Make sure we're checking x64 Registry
!ifdef DEBUG
StrCpy $RegPlatform "x64"
!endif
ReadRegStr $R0 HKLM "${JAVA_JRE_REGPATH}" "CurrentVersion"
IfErrors 0 JavaCheckDone
ReadRegStr $R0 HKLM "${JAVA_JDK_REGPATH}" "CurrentVersion"
# IfErrors 0 JavaCheckDone
# ReadRegStr $R0 HKLM "${JAVA_JRE_REGPATH2}" "CurrentVersion"
# IfErrors 0 JavaCheckDone
# ReadRegStr $R0 HKLM "${JAVA_JDK_REGPATH2}" "CurrentVersion"

JavaCheckDone:
!ifdef DEBUG
MessageBox MB_OK|MB_ICONINFORMATION "Java Version Detected: $R0 $RegPlatform"
!endif

IntCmp $R0 ${PRODUCT_MINJAVAVERSION} +3 0 +3
MessageBox MB_YESNO|MB_ICONQUESTION "${MSG_NOJAVA}" /SD IDNO IDNO +2
ExecShell "open" "${JAVA_DOWNLOAD_URL}"
SetRegView 32 # Make sure we're back to the x86 Registry
aerDNA#
This used to work fine:
Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.