Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 782c910

Browse files
authored
Release version 3.0.5 (PR #79)
Release version 3.0.5
2 parents 258cce3 + d2f781b commit 782c910

File tree

3 files changed

+89
-15
lines changed

3 files changed

+89
-15
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
ChangeLog
22
---------
33

4+
### v3.0.5 (2019-12-15)
5+
* If java is missing, offer a choice between Oracle and AdoptOpenJDK download buttons (#78)
6+
* Support Array style `Java:Arguments` for Apple Plist style (#76)
7+
* Bugfix: do not crash if `CFBundleIconFile` is provided without ".icns" extension (#75)
8+
* Minor French translation fix (PR #73, Thanks to @ebourg for his contribution)
9+
410
### v3.0.4 (2018-08-24)
511
* Bugfix: Variables `$APP_PACKAGE`, `$JAVAROOT`, `$USER_HOME` in `JVMOptions` key (Oracle) or `Java:Properties` key (Apple) were not expanded (#69)
612

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ Use whichever ANT task you like:
104104
* Oracle's opensource ["Appbundler"](https://java.net/projects/appbundler) *(seems to be dead)*
105105
* or [*infinitekind*'s fork](https://bitbucket.org/infinitekind/appbundler/overview)
106106

107+
Or build the App bundle statically from scratch...
108+
107109
### JarBundler (≥ v3.3) example
108110
Download the latest JarBundler release [from its github repo](https://github.com/UltraMixer/JarBundler).
109111

@@ -164,6 +166,49 @@ Supported PList keys
164166
| **Main Class Arguments** | `:Java(X):Arguments` | `:JVMArguments` |
165167

166168

169+
### Specify min/max Java requirement
170+
171+
Since v3.0 ([#51](https://github.com/tofi86/universalJavaApplicationStub/issues/51))
172+
173+
Use `Java(X):JVMVersion` (Apple style) or `:JVMVersion` (Oracle style) with the following values:
174+
175+
* `1.8` or `1.8*` for Java 8
176+
* `1.8+` for Java 8 or higher
177+
* `1.7;1.8*` for Java 7 or 8
178+
* `1.8;9.0` for Java 8* up to exactly 9.0 (but not 9.0.*)
179+
* `1.8;9.0*` for Java 8* and 9.0.* but not 9.1.*
180+
181+
182+
### Bundle a JRE/JDK with your app
183+
184+
You can use the Plist key `LSEnvironment` to export and set the `$JAVA_HOME` environment variable relative to your App's root directory:
185+
186+
```xml
187+
<key>LSEnvironment</key>
188+
<dict>
189+
<key>JAVA_HOME</key>
190+
<string>Contents/Frameworks/jdk8u232-b09-jre/Contents/Home</string>
191+
<dict>
192+
```
193+
194+
195+
Recommended additional Plist keys
196+
---------------------------------
197+
198+
Starting with Mac OS 10.14 users may be confronted with an additional system security dialog before any warning dialog of this stub is shown. See [issue #77](https://github.com/tofi86/universalJavaApplicationStub/issues/77) for more details.
199+
200+
This happens because the warning dialogs of this launcher stub are displayed with AppleScript.
201+
202+
It's recommended to at least set the following Plist key in order to display a descriptive message to the user, why he should grant the app system access:
203+
204+
```xml
205+
<key>NSAppleEventsUsageDescription</key>
206+
<string>There was an error while launching the application. Please click OK to display a dialog with more information or cancel and view the syslog for details.</string>
207+
```
208+
209+
The message itself is just a sample...
210+
211+
167212
Logging
168213
-------
169214

src/universalJavaApplicationStub

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# #
1212
# @author Tobias Fischer #
1313
# @url https://github.com/tofi86/universalJavaApplicationStub #
14-
# @date 2018-08-24 #
15-
# @version 3.0.4 #
14+
# @date 2019-12-15 #
15+
# @version 3.0.5 #
1616
# #
1717
##################################################################################
1818
# #
@@ -220,9 +220,14 @@ if [ $exitcode -eq 0 ]; then
220220
JVMDefaultOptions+=" -XstartOnFirstThread"
221221
fi
222222

223-
# read the JVM Arguments as an array and retain spaces
223+
# read the JVM Arguments in either Array or String style (#76) and retain spaces
224224
IFS=$'\t\n'
225-
MainArgs=($(xargs -n1 <<<$(plist_get_java ':Arguments')))
225+
MainArgs_RAW=$(plist_get_java ':Arguments' | xargs)
226+
if [[ $MainArgs_RAW == *Array* ]] ; then
227+
MainArgs=($(xargs -n1 <<<$(plist_get_java ':Arguments' | tr -d '\n' | sed -E 's/Array \{ *(.*) *\}/\1/g' | sed 's/ */ /g')))
228+
else
229+
MainArgs=($(xargs -n1 <<<$(plist_get_java ':Arguments')))
230+
fi
226231
unset IFS
227232
# post processing of the array follows further below...
228233

@@ -287,6 +292,18 @@ else
287292
fi
288293

289294

295+
# (#75) check for undefined icons or icon names without .icns extension and prepare
296+
# an osascript statement for those cases when the icon can be shown in the dialog
297+
DialogWithIcon=""
298+
if [ ! -z ${CFBundleIconFile} ]; then
299+
if [[ ${CFBundleIconFile} == *.icns ]] && [[ -f "${ResourcesFolder}/${CFBundleIconFile}" ]] ; then
300+
DialogWithIcon=" with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
301+
elif [[ ${CFBundleIconFile} != *.icns ]] && [[ -f "${ResourcesFolder}/${CFBundleIconFile}.icns" ]] ; then
302+
CFBundleIconFile+=".icns"
303+
DialogWithIcon=" with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
304+
fi
305+
fi
306+
290307

291308
# JVMVersion: post processing and optional splitting
292309
if [[ ${JVMVersion} == *";"* ]]; then
@@ -330,7 +347,8 @@ if [[ $LANG == fr* ]] ; then
330347
MSG_NO_SUITABLE_JAVA_CHECK="Merci de bien vouloir installer la version de Java requise."
331348
MSG_INSTALL_JAVA="Java doit être installé sur votre système.\nRendez-vous sur java.com et suivez les instructions d'installation..."
332349
MSG_LATER="Plus tard"
333-
MSG_VISIT_JAVA_DOT_COM="Visiter java.com"
350+
MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
351+
MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
334352

335353
# German localization
336354
elif [[ $LANG == de* ]] ; then
@@ -344,7 +362,8 @@ elif [[ $LANG == de* ]] ; then
344362
MSG_NO_SUITABLE_JAVA_CHECK="Stellen Sie sicher, dass die angeforderte Java-Version installiert ist."
345363
MSG_INSTALL_JAVA="Auf Ihrem System muss die 'Java'-Software installiert sein.\nBesuchen Sie java.com für weitere Installationshinweise."
346364
MSG_LATER="Später"
347-
MSG_VISIT_JAVA_DOT_COM="java.com öffnen"
365+
MSG_VISIT_JAVA_DOT_COM="Java von Oracle"
366+
MSG_VISIT_ADOPTOPENJDK="Java von AdoptOpenJDK"
348367

349368
# Simplifyed Chinese localization
350369
elif [[ $LANG == zh* ]] ; then
@@ -358,7 +377,8 @@ elif [[ $LANG == zh* ]] ; then
358377
MSG_NO_SUITABLE_JAVA_CHECK="请确保系统中安装了所需的Java版本"
359378
MSG_INSTALL_JAVA="你需要在Mac中安装Java运行环境!\n访问 java.com 了解如何安装。"
360379
MSG_LATER="稍后"
361-
MSG_VISIT_JAVA_DOT_COM="访问 java.com"
380+
MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
381+
MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
362382

363383
# English default localization
364384
else
@@ -372,7 +392,8 @@ else
372392
MSG_NO_SUITABLE_JAVA_CHECK="Make sure you install the required Java version."
373393
MSG_INSTALL_JAVA="You need to have JAVA installed on your Mac!\nVisit java.com for installation instructions..."
374394
MSG_LATER="Later"
375-
MSG_VISIT_JAVA_DOT_COM="Visit java.com"
395+
MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
396+
MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
376397
fi
377398

378399

@@ -513,7 +534,7 @@ if [ -z "${JAVACMD}" ] || [ ! -x "${JAVACMD}" ] ; then
513534
# log exit cause
514535
stub_logger "[EXIT 4] ${MSG_JVMVERSION_REQ_INVALID_EXPANDED}"
515536
# display error message with AppleScript
516-
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_JVMVERSION_REQ_INVALID_EXPANDED}\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1 with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
537+
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_JVMVERSION_REQ_INVALID_EXPANDED}\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1${DialogWithIcon}"
517538
# exit with error
518539
exit 4
519540
fi
@@ -523,7 +544,7 @@ if [ -z "${JAVACMD}" ] || [ ! -x "${JAVACMD}" ] ; then
523544
# log exit cause
524545
stub_logger "[EXIT 5] ${MSG_JVMVERSION_REQ_INVALID_EXPANDED}"
525546
# display error message with AppleScript
526-
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_JVMVERSION_REQ_INVALID_EXPANDED}\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1 with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
547+
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_JVMVERSION_REQ_INVALID_EXPANDED}\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1${DialogWithIcon}"
527548
# exit with error
528549
exit 5
529550
fi
@@ -700,19 +721,21 @@ if [ -z "${JAVACMD}" ] || [ ! -x "${JAVACMD}" ] ; then
700721
stub_logger "[EXIT 3] ${MSG_NO_SUITABLE_JAVA_EXPANDED}"
701722

702723
# display error message with AppleScript
703-
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_NO_SUITABLE_JAVA_EXPANDED}\n${MSG_NO_SUITABLE_JAVA_CHECK}\" with title \"${CFBundleName}\" buttons {\" OK \", \"${MSG_VISIT_JAVA_DOT_COM}\"} default button \"${MSG_VISIT_JAVA_DOT_COM}\" with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)" \
724+
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_NO_SUITABLE_JAVA_EXPANDED}\n${MSG_NO_SUITABLE_JAVA_CHECK}\" with title \"${CFBundleName}\" buttons {\" OK \", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTOPENJDK}\"} default button 1${DialogWithIcon}" \
704725
-e "set response to button returned of the result" \
705-
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"http://java.com\""
726+
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"https://www.java.com/download/\"" \
727+
-e "if response is \"${MSG_VISIT_ADOPTOPENJDK}\" then open location \"https://adoptopenjdk.net/releases.html\""
706728
# exit with error
707729
exit 3
708730

709731
else
710732
# log exit cause
711733
stub_logger "[EXIT 1] ${MSG_ERROR_LAUNCHING}"
712734
# display error message with AppleScript
713-
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_INSTALL_JAVA}\" with title \"${CFBundleName}\" buttons {\"${MSG_LATER}\", \"${MSG_VISIT_JAVA_DOT_COM}\"} default button \"${MSG_VISIT_JAVA_DOT_COM}\" with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)" \
735+
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_INSTALL_JAVA}\" with title \"${CFBundleName}\" buttons {\"${MSG_LATER}\", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTOPENJDK}\"} default button 1${DialogWithIcon}" \
714736
-e "set response to button returned of the result" \
715-
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"http://java.com\""
737+
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"https://www.java.com/download/\"" \
738+
-e "if response is \"${MSG_VISIT_ADOPTOPENJDK}\" then open location \"https://adoptopenjdk.net/releases.html\""
716739
# exit with error
717740
exit 1
718741
fi
@@ -727,7 +750,7 @@ if [ -z "${JVMMainClass}" ]; then
727750
# log exit cause
728751
stub_logger "[EXIT 2] ${MSG_MISSING_MAINCLASS}"
729752
# display error message with AppleScript
730-
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_MISSING_MAINCLASS}\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1 with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
753+
osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_MISSING_MAINCLASS}\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1${DialogWithIcon}"
731754
# exit with error
732755
exit 2
733756
fi

0 commit comments

Comments
 (0)