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

Commit 719ca7c

Browse files
committed
Merge pull request #1 from dpolivaev/master
All options not enclosed in quotes but taken separately + Java folder should be used as working directory
2 parents 0258b9c + 59b066d commit 719ca7c

1 file changed

Lines changed: 35 additions & 31 deletions

File tree

src/universalJavaApplicationStub

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/sh
2-
32
##################################################################################
43
# #
54
# universalJavaApplicationStub #
@@ -26,7 +25,7 @@
2625
# Copyright (c) 2014 Tobias Fischer #
2726
# #
2827
# Permission is hereby granted, free of charge, to any person obtaining a copy #
29-
# of this software and associated documentation files (the "Software"), to deal #
28+
# of this software and associated documentation files (the "Software"), to deal #
3029
# in the Software without restriction, including without limitation the rights #
3130
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #
3231
# copies of the Software, and to permit persons to whom the Software is #
@@ -92,41 +91,43 @@ CFBundleIconFile=`/usr/libexec/PlistBuddy -c "print :CFBundleIconFile" ${InfoPli
9291

9392
# read Info.plist in Apple style
9493
if [ -d "${AppleJavaFolder}" ]; then
95-
96-
# set classpath
97-
JVMClasspath="${AppleJavaFolder}*"
98-
94+
95+
# set working directory
96+
JavaFolder="${AppleJavaFolder}"
97+
ResourcesFolder=".."
98+
9999
# read the MainClass name
100100
JVMMainClass=`/usr/libexec/PlistBuddy -c "print :Java:MainClass" ${InfoPlistFile} 2> /dev/null`
101-
101+
102102
# read the JVM Options
103103
JVMOptions=`/usr/libexec/PlistBuddy -c "print :Java:Properties" ${InfoPlistFile} 2> /dev/null | grep " =" | sed 's/^ */-D/g' | tr '\n' ' ' | sed 's/ */ /g' | sed 's/ = /=/g' | xargs`
104-
104+
105105
# read the JVM Default Options
106106
JVMDefaultOptions=`/usr/libexec/PlistBuddy -c "print :Java:VMOptions" ${InfoPlistFile} 2> /dev/null | xargs`
107-
107+
108108
# read the JVM Arguments
109109
JVMArguments=`/usr/libexec/PlistBuddy -c "print :Java:Arguments" ${InfoPlistFile} 2> /dev/null | xargs`
110110

111111

112112
# read Info.plist in Oracle style
113113
elif [ -d "${OracleJavaFolder}" ]; then
114-
115-
# set classpath
116-
JVMClasspath="${OracleJavaFolder}*"
117-
114+
115+
# set working directory
116+
JavaFolder="${OracleJavaFolder}"
117+
ResourcesFolder="../Resources"
118+
118119
# read the MainClass name
119120
JVMMainClass=`/usr/libexec/PlistBuddy -c "print :JVMMainClassName" ${InfoPlistFile} 2> /dev/null`
120-
121+
121122
# read the JVM Options
122123
JVMOptions=`/usr/libexec/PlistBuddy -c "print :JVMOptions" ${InfoPlistFile} 2> /dev/null | grep " -" | tr '\n' ' ' | sed 's/ */ /g' | xargs`
123-
124+
124125
# read the JVM Default Options
125126
JVMDefaultOptions=`/usr/libexec/PlistBuddy -c "print :JVMDefaultOptions" ${InfoPlistFile} 2> /dev/null | grep -o "\-.*" | tr '\n' ' ' | xargs`
126-
127+
127128
# read the JVM Arguments
128129
JVMArguments=`/usr/libexec/PlistBuddy -c "print :JVMArguments" ${InfoPlistFile} 2> /dev/null | tr '\n' ' ' | sed -E 's/Array \{ *(.*) *\}/\1/g' | sed 's/ */ /g' | xargs`
129-
130+
130131
fi
131132

132133

@@ -162,21 +163,23 @@ fi
162163
#
163164
# execute JAVA commandline and do some pre-checks
164165
####################################################
165-
166+
166167
# display error message if MainClassName is empty
167168
if [ ${JVMMainClass} == "" ]; then
168169
# display error message with applescript
169170
osascript -e "tell application \"System Events\" to display dialog \"ERROR launching ${CFBundleName}!\n\nNo MainClassName specified!\nJava application cannot be started!\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1 with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
170171
# exit with error
171172
exit 1
172-
173-
173+
174+
174175
# check whether $JAVACMD is executable
175176
elif [ -x "$JAVACMD" ]; then
176177

177178
# enable drag&drop to the dock icon
178179
export CFProcessPath="$0"
179-
180+
181+
cd "$JavaFolder"
182+
180183
# execute Java and set
181184
# - classpath
182185
# - dock icon
@@ -186,23 +189,24 @@ elif [ -x "$JAVACMD" ]; then
186189
# - main class
187190
# - JVM arguments
188191
exec "$JAVACMD" \
189-
-cp "${JVMClasspath}" \
190-
-Xdock:icon="$PROGDIR/../Resources/${CFBundleIconFile}" \
192+
-cp "./*" \
193+
-Xdock:icon="$ResourcesFolder/${CFBundleIconFile}" \
191194
-Xdock:name="${CFBundleName}" \
192-
${JVMOptions:+"$JVMOptions" }\
193-
${JVMDefaultOptions:+"$JVMDefaultOptions" }\
195+
${JVMOptions:+$JVMOptions }\
196+
${JVMDefaultOptions:+$JVMDefaultOptions }\
194197
"${JVMMainClass}"\
195-
${JVMArguments:+"$JVMArguments"}
196-
197-
198+
${JVMArguments:+$JVMArguments}
199+
200+
198201
else
199202

200203
# display error message with applescript
201204
osascript -e "tell application \"System Events\" to display dialog \"ERROR launching ${CFBundleName}!\n\nYou need to have JAVA installed on your Mac!\nVisit http://java.com for more information...\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1 with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
202-
205+
203206
# and open java.com
204207
open http://java.com
205-
208+
206209
# exit with error
207210
exit 1
208-
fi
211+
fi
212+

0 commit comments

Comments
 (0)