I want to install Java using an NSIS script, but i have to know whether Java is installed or not in the system (Windows). based on the register keys how can we check if Java
I didn't compile it, but I would try following. I chose registry key based on How can I detect the installed Sun JRE on Windows?.
;--------------------------------
;Defines
!define JavaRegKey 'HKLM "Software\JavaSoft\Java Runtime Environment" ""'
;--------------------------------
;Installer Sections
Section 'Java Runtime' SecJava
SetOutPath '$TEMP'
SetOverwrite on
File 'c:\\javasetup.exe'
ExecWait '$TEMP\javasetup.exe' $0
DetailPrint '..Java Runtime Setup exit code = $0'
Delete '$TEMP\javasetup.exe'
SectionEnd
;--------------------------------
; Functions
Function .onInit
ReadRegStr $R0 ${JavaRegKey}
StrCmp $R0 "" JavaMissing JavaFound
JavaFound:
!insertmacro UnselectSection ${SecJava}
Goto JavaCheckDone
JavaMissing:
!insertmacro SelectSection ${SecJava}
JavaCheckDone:
FunctionEnd