Archive: I want to add automatic JRE Installation during installing my exe file


I want to add automatic JRE Installation during installing my exe file
Hi friends....
I want to create a set up for my jar file and during installation I want check whether JRE is installed in end user system, if not then it should be automatically installed.
I got the following URL
http://nsis.sourceforge.net/Java_Lau...E_installation
but I am not able to understand what I should do ????
Please tell me step by step that how I can check JRE and automatically installed in end user system.
Please help me....
Thanks in advance.....


JRE install detection and installation
first: you have to access to the registry of the machine and test if the JRE path exists;
second: if not install it in silent mode if you don't want the user to interact with the java installation;
third: add the JAVA_HOME and the %JAVA_HOME%\bin to the Envinroment Path;
example, for detecting if a specific JRE is installed in this case 1.6.0_24:
Inside a section put this code:
SetRegView 32
;test for java 1.6.024
ReadRegStr $1 HKLM 'SOFTWARE\JavaSoft\Java Development Kit' CurrentVersion
IfErrors 0 noJavaInstall
Call javaInstall
Goto doneJava
noJavaInstall:
ReadRegStr $1 HKLM 'SOFTWARE\JavaSoft\Java Development Kit\1.6.0_24' JavaHome
IfErrors 0 doneJava
ReadRegStr $1 HKLM 'SOFTWARE\JavaSoft\Java Development Kit' CurrentVersion
MessageBox MB_OK 'The current Java Version is $1, the Java version required/recommended for the application is 1.6.0_24. You may unistall this version and run this installer later ad the recommended version will be installed.'
doneJava:

Then create the installation function:
Function javaInstall
SetOutPath "$INSTDIR\instals"
File "${JAVA}"

ExecWait '"$INSTDIR\instals\jdk-6u24-windows-i586.exe" /passive'
;installation path
ReadRegStr $1 HKLM 'SOFTWARE\JavaSoft\Java Development Kit\1.6.0_24' "JavaHome"
;set JavaHome in user
WriteRegStr HKCU "Environment" "JAVA_HOME" "$1"
ReadRegStr $3 HKCU Environment "PATH"
StrCpy $2 '$3;$1\bin'
;set path in user
WriteRegStr HKCU "Environment" "PATH" "$2"
FunctionEnd
There is a catch, restart the machine after the install or use the setx windows command to set the Environment variables so they can be used at once.