How do I select the JRE version used by the Java Launcher?AnswerAdvanced Installer allows you to set the Java Runtime Environment versions which can be used by your Java application through the Settings tab of the Java Products page. However, you may want to allow your users to select the JRE version when the package runs. Configure the installation packageBefore implementing the feature which allows the user to select a JRE version, you need to configure your Advanced Installer project. For this you can follow these steps:
The custom INI file will use the "JRE_COMBO" property to tell the Java Launcher the path of the JRE it must use. The entries in this INI file will be added to the INI used by the Java Launcher because of the "Install folder content into the parent folder" option. Create the custom actionsIn order to get the JRE versions installed on the system and place them into a combo box you can use two custom actions: a VBScript custom action which reads the JRE versions from the registry and the predefined PopulateComboBox custom action. The custom action which enumerates the registry keys under HKLM\SOFTWARE\JavaSoft\Java Runtime Environment adds the JRE versions and their paths to the AI_COMBOBOX_DATA property. This property is used by the "PopulateComboBox" custom action to populate the JRE_COMBO combo box. Here is a sample VBScript custom action which reads the registry and sets the "AI_COMBOBOX_DATA" property (I called it "getJreVersions.vbs"): 'declare and initialize the variables
Dim ComboString
ComboString = "JRE_COMBO" & "|"
Dim text(10)
Dim value(10)
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
'set the path of the registry entry which contains the JRE versions
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\JavaSoft\Java Runtime Environment"
strValue = "JavaHome"
'get the JRE versions
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
'place the JRE versions in two containers
indexReg = 1
For Each strKey In arrSubKeys
strJavaHome = strKeyPath & "\" & strKey
objReg.GetStringValue HKEY_LOCAL_MACHINE, strJavaHome, strValue, javaPath
text(indexReg) = strKey
value(indexReg) = JavaPath
indexReg = indexReg + 1
Next
indexReg = indexReg - 1
indexCombo = indexReg
'create the string for AI_COMBOBOX_DATA
For indexCombo = indexReg to 1 Step -1
ok = "not present"
j = indexCombo + 1
'make sure that the values are unique
For i = indexReg to j Step -1
if value(i) = value(indexCombo) then
ok = "present"
End if
Next
if ok="not present" then
ComboString = ComboString & value(indexCombo)& "#" & text(indexCombo) & "|"
End if
Next
'set the AI_COMBOBOX_DATA property
Session.Property("AI_COMBOBOX_DATA") = ComboString
'set the default value of the combo to the latest JRE version
Session.Property("JRE_COMBO") = JavaPathBasically, here is what happens when this custom action is executed
Configure the User InterfaceAfter configuring the Java product and creating the custom action, you need to configure the UI of your installation package. Here are the steps you can take:
DoAction getJreVersions.vbs 1 DoAction PopulateComboBox 1 Sample projectYou can download a sample project from here. | |
| Privacy Policy | Windows Installer | Search Engine Ranking | Link Analyzer | ||
| © 2002 - 2008 Caphyon Ltd. Trademarks belong to their respective owners. All rights reserved. | ||