Prev Previous Post   Next Post Next
Old 9th November 2015, 13:21   #1
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"

; Fall-back to 32-bit registry
${If} ${RunningX64}
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

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
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