I have an NSIS installer that at some point should check to see if java is installed on the system, and if not, it should install it silently. It should also return the path to java, because I need to create a JAVA_HOME environment variable.
This is the function I wrote to test java installation and save java path in a 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 Messagebox 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 Messagebox MB_OK "Javahome value: $JavaInstallationPath" ${EndIf} ${EndIf} NoJava: Messagebox MB_OK "No Java installation detected. Installing Java." # Install Java Messagebox 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 Messagebox MB_OK "Java installation path: $JavaInstallationPath" FunctionEnd
Later in the installer, I install the service with a ruby ββscript:
nsExec::ExecToLog 'jruby "$INSTDIR\Application\install\install_service.rb"'
(what is inside this .rb file does not cause problems, because I tried hard to specify the path to java, and everything worked fine)
However, everything works fine on 32-bit operating systems. But when I run the installer on 64-bit systems, this service does not start, returning error 1067.
At first I thought that the FindJava function FindJava not work correctly and caused the service to be installed incorrectly, but I sent all the results to message boxes, and they are exactly as expected.
Unfortunately, the problem is really in this function. I removed the function, I had hardcoded $ JavaInstallationPath, and the installer worked.
I really don't know what is wrong. Please, help.