Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ${SegmentFile}
- Var UsingJavaExecutable
- Var JavaMode
- Var JavaDirectory
- Var JDKMode
- Var JDKDirectory
- ${SegmentInit}
- ; If [Activate]:Java=find|require, search for Java in the following
- ; locations (in order):
- ;
- ; - PortableApps.com CommonFiles (..\CommonFiles\Java)
- ; - Registry (HKLM\Software\JavaSoft\Java Runtime Environment)
- ; - %JAVA_HOME%
- ; - Anywhere in %PATH% (with SearchPath)
- ; - %WINDIR%\Java (from Windows 98, probably obsolete now we don't it)
- ;
- ; If it's in none of those, give up. [Activate]:Java=require will then
- ; abort, [Activate]:Java=find will set it to the non-existent CommonFiles
- ; location. %JAVA_HOME% is then set to the location.
- ClearErrors
- ${ReadLauncherConfig} $JavaMode Activate Java
- ${If} $JavaMode == find
- ${OrIf} $JavaMode == require
- StrCpy $JavaDirectory $PortableAppsDirectory\CommonFiles\Java
- ${IfNot} ${FileExists} $JavaDirectory
- ClearErrors
- ReadRegStr $0 HKLM "Software\JavaSoft\Java Runtime Environment" CurrentVersion
- ReadRegStr $JavaDirectory HKLM "Software\JavaSoft\Java Runtime Environment\$0" JavaHome
- ${If} ${Errors}
- ${OrIfNot} ${FileExists} $JavaDirectory\bin\java.exe
- ${AndIfNot} ${FileExists} $JavaDirectory\bin\javaw.exe
- ClearErrors
- ReadEnvStr $JavaDirectory JAVA_HOME
- ${If} ${Errors}
- ${OrIfNot} ${FileExists} $JavaDirectory\bin\java.exe
- ${AndIfNot} ${FileExists} $JavaDirectory\bin\javaw.exe
- ClearErrors
- SearchPath $JavaDirectory java.exe
- ${IfNot} ${Errors}
- ${GetParent} $JavaDirectory $JavaDirectory
- ${GetParent} $JavaDirectory $JavaDirectory
- ${Else}
- StrCpy $JavaDirectory $WINDIR\Java
- ${IfNot} ${FileExists} $JavaDirectory\bin\java.exe
- ${AndIfNot} ${FileExists} $JavaDirectory\bin\javaw.exe
- StrCpy $JavaDirectory $PortableAppsDirectory\CommonFiles\Java
- ${DebugMsg} "Unable to find Java installation."
- ${EndIf}
- ${EndIf}
- ${EndIf}
- ${EndIf}
- ${EndIf}
- ; Also, if [Activate]:JDK=find|require is set as well (Java must also be set),
- ; search for the JDK in these locations (in order):
- ;
- ; - JDK_HOME user setting in the AppNamePortable.ini file
- ; - [Java]:JDK_HOME
- ; - PortableApps.com CommonFiles (..\CommonFiles\JDK)
- ; - Registry (HKLM\Software\JavaSoft\Java Development Kit)
- ; - %JDK_HOME%
- ;
- ; As above, [Activate]:JDK=require will abort if the JDK hasn't been found.
- ; Note that, the [Java]:JDK_HOME option can be set a custom location on a
- ; per application basis. The user can override this setting by setting
- ; JDK_HOME in the AppNamePortable.ini file.
- ; Then populate %JDK_HOME% with the JDK location.
- ${ReadLauncherConfig} $JDKMode Activate JDK
- ${If} $JDKMode == find
- ${OrIf} $JDKMode == require
- ; Set the Default JDKDirectory
- StrCpy $JDKDirectory $PortableAppsDirectory\CommonFiles\JDK
- ; Read the settings
- ${ReadUserConfig} $0 JDK_HOME
- ${ReadLauncherConfig} $1 Java JDK_HOME
- ; Reset JDKDirectory according to those settings
- ${IfNot} $0 == ''
- StrCpy $JDKDirectory $0
- ${ElseIfNot} $1 == ''
- StrCpy $JDKDirectory $1
- ${EndIf}
- ${IfNot} ${FileExists} $JDKDirectory
- ClearErrors
- ReadRegStr $0 HKLM "Software\JavaSoft\Java Development Kit" CurrentVersion
- ReadRegStr $JDKDirectory HKLM "Software\JavaSoft\Java Development Kit\$0" JavaHome
- ${If} ${Errors}
- ${OrIfNot} ${FileExists} $JDKDirectory\bin\java.exe
- ClearErrors
- ReadEnvStr $JDKDirectory JDK_HOME
- ${If} ${Errors}
- ${OrIfNot} ${FileExists} $JDKDirectory\bin\java.exe
- StrCpy $JavaDirectory $PortableAppsDirectory\CommonFiles\JDK
- ${DebugMsg} "Unable to find JDK installation."
- ${EndIf}
- ${EndIf}
- ${EndIf}
- ${ElseIfNot} ${Errors}
- ${InvalidValueError} [Activate]:JDK $JDKMode
- ${EndIf}
- ; If Java is required and not found, quit; if it is, check if
- ; [Launch]:ProgramExecutable is java.exe or javaw.exe.
- ${If} $JavaMode == require
- ${IfNot} ${FileExists} $JavaDirectory
- ;=== Java Portable is missing
- MessageBox MB_OK|MB_ICONSTOP `$(LauncherNoJava)`
- Quit
- ${EndIf}
- ${IfThen} $ProgramExecutable == java.exe ${|} StrCpy $UsingJavaExecutable true ${|}
- ${IfThen} $ProgramExecutable == javaw.exe ${|} StrCpy $UsingJavaExecutable true ${|}
- ${If} $UsingJavaExecutable == true
- ${AndIfNot} ${FileExists} $JavaDirectory\bin\$ProgramExecutable
- ;=== The required Java binary (java.exe or javaw.exe) is missing.
- MessageBox MB_OK|MB_ICONSTOP `$(LauncherNoJava)`
- Quit
- ${EndIf}
- ${EndIf}
- ; If JDK is required and not found, quit. (Reuses the LauncherNoJava error message)
- ${If} $JDKMode == require
- ${IfNot} ${FileExists} $JDKDirectory
- ;=== JDK Portable is missing
- MessageBox MB_OK|MB_ICONSTOP `$(LauncherNoJava)`
- Quit
- ${EndIf}
- ${EndIf}
- ; Now set %JAVA_HOME% to the path (still may not exist)
- ${DebugMsg} "Selected Java path: $JavaDirectory"
- ${SetEnvironmentVariablesPath} JAVA_HOME $JavaDirectory
- ; Now set %JDK_HOME% to the path (still may not exist)
- ${DebugMsg} "Selected JDK path: $JDKDirectory"
- ${SetEnvironmentVariablesPath} JDK_HOME $JDKDirectory
- ${ElseIfNot} ${Errors}
- ${InvalidValueError} [Activate]:Java $JavaMode
- ${EndIf}
- !macroend
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement