Advertisement
Guest User

Java.nsh (patched for JDK support), patch against PAL 2.1

a guest
Jun 4th, 2011
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- E:/Workspaces/sts/PA.c-Launcher/Other/Source/Segments/Java.nsh.orig Sun May 08 17:12:16 2011
  2. +++ E:/Workspaces/sts/PA.c-Launcher/Other/Source/Segments/Java.nsh  Thu Jun 02 22:12:54 2011
  3. @@ -3,6 +3,8 @@
  4.  Var UsingJavaExecutable
  5.  Var JavaMode
  6.  Var JavaDirectory
  7. +Var JDKMode
  8. +Var JDKDirectory
  9.  
  10.  ${SegmentInit}
  11.     ; If [Activate]:Java=find|require, search for Java in the following
  12. @@ -51,6 +53,54 @@
  13.             ${EndIf}
  14.         ${EndIf}
  15.  
  16. +                ; Also, if [Activate]:JDK=find|require is set as well (Java must also be set),
  17. +                ; search for the JDK in these locations (in order):
  18. +                ;
  19. +                ;  - JDK_HOME user setting in the AppNamePortable.ini file
  20. +                ;  - [Java]:JDK_HOME
  21. +                ;  - PortableApps.com CommonFiles (..\CommonFiles\JDK)
  22. +                ;  - Registry (HKLM\Software\JavaSoft\Java Development Kit)
  23. +                ;  - %JDK_HOME%
  24. +                ;
  25. +                ; As above, [Activate]:JDK=require will abort if the JDK hasn't been found.
  26. +                ; Note that, the [Java]:JDK_HOME option can be set a custom location on a
  27. +                ; per application basis. The user can override this setting by setting
  28. +                ; JDK_HOME in the AppNamePortable.ini file.
  29. +                ; Then populate %JDK_HOME% with the JDK location.
  30. +       ${ReadLauncherConfig} $JDKMode Activate JDK
  31. +       ${If} $JDKMode == find
  32. +                ${OrIf} $JDKMode == require
  33. +                        ; Set the Default JDKDirectory
  34. +                        StrCpy $JDKDirectory $PortableAppsDirectory\CommonFiles\JDK
  35. +                        ; Read the settings
  36. +                        ${ReadUserConfig} $0 JDK_HOME
  37. +                        ${ReadLauncherConfig} $1 Java JDK_HOME
  38. +                        ; Reset JDKDirectory according to those settings
  39. +                        ${IfNot} $0 == ''
  40. +                           StrCpy $JDKDirectory $0
  41. +                        ${ElseIfNot} $1 == ''
  42. +                                StrCpy $JDKDirectory $1
  43. +                        ${EndIf}
  44. +                        
  45. +                        ${IfNot} ${FileExists} $JDKDirectory
  46. +                   ClearErrors
  47. +                   ReadRegStr $0 HKLM "Software\JavaSoft\Java Development Kit" CurrentVersion
  48. +                   ReadRegStr $JDKDirectory HKLM "Software\JavaSoft\Java Development Kit\$0" JavaHome
  49. +                   ${If} ${Errors}
  50. +                   ${OrIfNot} ${FileExists} $JDKDirectory\bin\java.exe
  51. +                       ClearErrors
  52. +                       ReadEnvStr $JDKDirectory JDK_HOME
  53. +                       ${If} ${Errors}
  54. +                       ${OrIfNot} ${FileExists} $JDKDirectory\bin\java.exe
  55. +                       StrCpy $JavaDirectory $PortableAppsDirectory\CommonFiles\JDK
  56. +                       ${DebugMsg} "Unable to find JDK installation."
  57. +                       ${EndIf}
  58. +                   ${EndIf}
  59. +               ${EndIf}
  60. +                ${ElseIfNot} ${Errors}
  61. +                        ${InvalidValueError} [Activate]:JDK $JDKMode
  62. +                ${EndIf}
  63. +                
  64.         ; If Java is required and not found, quit; if it is, check if
  65.         ; [Launch]:ProgramExecutable is java.exe or javaw.exe.
  66.         ${If} $JavaMode == require
  67. @@ -68,10 +118,21 @@
  68.                 Quit
  69.             ${EndIf}
  70.         ${EndIf}
  71. +       ; If JDK is required and not found, quit. (Reuses the LauncherNoJava error message)
  72. +       ${If} $JDKMode == require
  73. +           ${IfNot} ${FileExists} $JDKDirectory
  74. +               ;=== JDK Portable is missing
  75. +               MessageBox MB_OK|MB_ICONSTOP `$(LauncherNoJava)`
  76. +               Quit
  77. +           ${EndIf}
  78. +       ${EndIf}
  79.  
  80.         ; Now set %JAVA_HOME% to the path (still may not exist)
  81.         ${DebugMsg} "Selected Java path: $JavaDirectory"
  82.         ${SetEnvironmentVariablesPath} JAVA_HOME $JavaDirectory
  83. +       ; Now set %JDK_HOME% to the path (still may not exist)
  84. +       ${DebugMsg} "Selected JDK path: $JDKDirectory"
  85. +       ${SetEnvironmentVariablesPath} JDK_HOME $JDKDirectory
  86.     ${ElseIfNot} ${Errors}
  87.         ${InvalidValueError} [Activate]:Java $JavaMode
  88.     ${EndIf}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement