NSIS – detect problems with Java installations on x64 systems
I have an NSIS installer. At some point, I must check whether Java is installed in the system. If not, it must install it silently It must also return the path to Java because I have to create Java_ Home environment variable
This is the function I wrote to check the Java installation and save the Java path in the variable:
Var JavaInstallationPath
Function FindJava
Strcpy $1 "SOFTWARE\JavaSoft\Java Runtime Environment"
Strcpy $2 0
ReadRegStr $2 HKLM "$1" "CurrentVersion"
${If} $2 == ""
Goto DetectTry2
${Else}
ReadRegStr $5 HKLM "$1\$2" "JavaHome"
${If} $5 == ""
Goto DetectTry2
${Else}
Strcpy $JavaInstallationPath $5
Message@R_721_2419@ MB_OK "Javahome value: $JavaInstallationPath"
${EndIf}
${EndIf}
DetectTry2:
ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Development Kit" "CurrentVersion"
${If} $2 == ""
Goto NoJava
${Else}
ReadRegStr $5 HKLM "SOFTWARE\JavaSoft\Java Development Kit\$2" "JavaHome"
${If} $5 == ""
Goto NoJava
${Else}
Strcpy $JavaInstallationPath $5
Message@R_721_2419@ MB_OK "Javahome value: $JavaInstallationPath"
${EndIf}
${EndIf}
NoJava:
Message@R_721_2419@ MB_OK "No Java installation detected. Installing Java."
# Install Java
Message@R_721_2419@ MB_OK "Running x32"
ExecWait "$INSTDIR\temp\jre-6u26-windows-i586.exe"
# get jre path value after installation
Strcpy $1 "SOFTWARE\JavaSoft\Java Runtime Environment"
Strcpy $2 0
ReadRegStr $2 HKLM "$1" "CurrentVersion"
ReadRegStr $5 HKLM "$1\$2" "JavaHome"
Strcpy $JavaInstallationPath $5
Message@R_721_2419@ MB_OK "Java installation path: $JavaInstallationPath"
FunctionEnd
Later in the installer, I installed a service that runs Ruby scripts:
nsExec::ExecToLog 'jruby "$INSTDIR\Application\install\install_service.rb"'
(. RB file will not cause problems, because I tried to hard code the Java path, and everything is normal)
However, everything applies to 32 - bit operating systems However, when I run setup on a 64 bit system, the service will fail to start with error 1067
At first, I thought the findjava function didn't work properly and led to the installation error of the service, but I sent all the results to the message box, and they were exactly what I expected
Unfortunately, the problem is actually this function I deleted this function, I have hard coded $Java installationpath, and the installer works normally
I really don't know what's wrong Please help.
Solution
Windows exit code 1067 refers to "unexpected termination of the process" see http://www.chicagotech.net/troubleshooting/exitcode2.htm
I try to check if there is any problem running jruby on Windows 64 bit, and there is! Check this link:
http://hype-free.blogspot.com/2011/09/running-jruby-on-64-bit-windows.html
But I think if jruby Jar depends on the currently installed Java runtime to run it, but without the Java runtime installed, it may not run at all
