Archive: How to get JRE version dynamically?

How to get JRE version dynamically?
Function java
SetOutPath '$TEMP'
SetOverwrite on
File lib\jre-6u24-x64.exe
ExecWait '$TEMP\jre-6u24-x64.exe'

If the user change JRE version 24 to 29(jre-6u24-x64.exe changed to jre-6u29-x64.exe),the above code is not working.
Is possible to identify JRE version ? How to install dynamically install JRE?

I don't understand how the user does change the version (file)?
You provide the file with the "File lib\jre-6u24-x64.exe" command, so the user is not able to change it.

See this topic for detecting JRE version (from Registry):