I've been using NSIS to create an installer for windows. I have a section in my installer containing the installation of a Runnable JAR. for which my customers need JRE 1.8+ to run the application.
In order to check whether or not my customers have the correct JRE i use following code. It also downloads the JRE from the download link.
I got this piece of code from the examples from NSIS sourceforge page.Function GetJRE
MessageBox MB_OK "${PRODUCT_NAME} uses Java ${JRE_VERSION}, it will now \
be downloaded and installed"
StrCpy $2 "$TEMP\Java Runtime Environment.exe"
nsisdl::download /TIMEOUT=30000 ${JRE_URL} $2
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
MessageBox MB_OK "Download failed: $R0"
Quit
ExecWait $2
Delete $2
FunctionEnd
Function DetectJRE
ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" \
"CurrentVersion"
StrCmp $2 ${JRE_VERSION} done
ReadRegStr $3 HKLM "SOFTWARE\JavaSoft\Java Development Kit" "CurrentVersion"
StrCmp $3 ${JRE_VERSION} done
Call GetJRE
done:
FunctionEnd
It works fine for me and on a virtual machine with no java or a older version of java it works all fine. So java version 1.7 and lower gets detected and newer version of java gets downloaded with the following link
javadl.oracle.com/webapps/download/AutoDL?BundleId=210176
This is the online installer for the 8u91.
Now if I distribute my installer to customers. They get the Download failed: Download incomplete error message.
So I did a teamviewer session with someone with this problem. And copy and pasted the download link from my nsis file (which works fine for me and my pc) but when i copy and paste it in their browser it says netwerk fail. They have a internet connection so it's not that they don't have internet access.
after a while searching i found the offline installer on official java site. and tried copying this url and pasting it in my browers which works and copy and paste it in customer browser over teamviewer and it works.
So for some reason the online installer link won't work on their computers.
Does anyone else has had this problem before?
I've read the second last post from this thread:
forums.winamp.com/showthread.php?t=310480&highlight=java+download
but if i insert this code into my installer i get the error:
thanks for helping me out.!include: closed: "C:\Program Files (x86)\NSIS\Include\OnlineUpdate.nsh"
!insertmacro: UpdateXml
Invalid command: xml::_LoadFile
Error in macro xml::LoadFile on macroline 1
Error in macro UpdateXml on macroline 18
Error in script "v2.nsi" on line 51 -- aborting creation process