Old 9th November 2015, 14:21   #1
qzind
Junior Member
 
Join Date: Nov 2015
Posts: 1
Better Java Detection

The A_slightly_better_Java_Launcher example in the Wiki fails to detect a 32-bit Java run-time on a 64-bit machine, which is common considering the amount of users which historically installed 32-bit Java for Chrome/Firefox.

The codeblock should help discover the 32-bit version (requires x64.nsh). This can go immediately before StrCpy $R0 "javaw.exe"

code:
; Fall-back to 32-bit registry
${If} ${RunningX64}
ClearErrors
ReadRegStr $R1 HKLM "Software\Wow6432Node\JavaSoft\Java Runtime Environment" "CurrentVersion"
ReadRegStr $R0 HKLM "Software\Wow6432Node\JavaSoft\Java Runtime Environment\$R1" "JavaHome"
StrCpy $R0 "$R0\bin\javaw.exe"
IfErrors 0 JreFound
${EndIf}




However, due to the redirecting of ProgramFiles to ProgramFiles(x86) this still will have problem if the NSIS installer is in 32-bit mode, so some additional 64-bit detection logic is still required. The full source can be viewed here.

I haven't converted this example for generic usage yet, but it should be trivial to remove the variables our code is using and replace them with your own.
qzind is offline   Reply With Quote
Old 29th November 2015, 15:50   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,321
It would be nice if you could update the wiki. I don't have Java installed so I cannot really look into the ProgramFiles(x86) issue...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump