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

Commit 99f2d7f

Browse files
committed
support for JVMVersion plist key // fixes #13
1 parent cabe320 commit 99f2d7f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/universalJavaApplicationStub

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ OracleResourcesFolder="${AppPackageFolder}"/Contents/Resources
9696
# set path to Info.plist in bundle
9797
InfoPlistFile="${AppPackageFolder}"/Contents/Info.plist
9898

99+
# set the default JVM Version to a null string
100+
JVMVersion=""
99101

100102

101103

@@ -171,6 +173,8 @@ if [ $exitcode -eq 0 ]; then
171173
# read the JVM Arguments
172174
JVMArguments=`/usr/libexec/PlistBuddy -c "print :Java:Arguments" "${InfoPlistFile}" 2> /dev/null | xargs`
173175

176+
# read the Java version we want to find
177+
JVMVersion=`/usr/libexec/PlistBuddy -c "print :Java:JVMVersion" "${InfoPlistFile}" 2> /dev/null | xargs`
174178

175179
# read Info.plist in Oracle style
176180
else
@@ -211,6 +215,18 @@ fi
211215
# first check system variable "$JAVA_HOME"
212216
if [ -n "$JAVA_HOME" ] ; then
213217
JAVACMD="$JAVA_HOME/bin/java"
218+
219+
# check for specified JVMversion in "/usr/libexec/java_home" symlinks
220+
elif [ ! -z ${JVMVersion} ] && [ -x /usr/libexec/java_home ] ; then
221+
222+
if /usr/libexec/java_home -F -v ${JVMVersion}; then
223+
JAVACMD="`/usr/libexec/java_home -F -v ${JVMVersion} 2> /dev/null`/bin/java"
224+
else
225+
# display error message with applescript
226+
osascript -e "tell application \"System Events\" to display dialog \"ERROR launching '${CFBundleName}'\n\nNo suitable Java version found on your system!\nThis program requires Java ${JVMVersion}\nMake sure you install the required Java version.\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1 with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
227+
# exit with error
228+
exit 1
229+
fi
214230

215231
# otherwise check "/usr/libexec/java_home" symlinks
216232
elif [ -x /usr/libexec/java_home ] && [ -d "`/usr/libexec/java_home 2> /dev/null`" ] ; then

0 commit comments

Comments
 (0)