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

Commit 9587c16

Browse files
author
dpolivaev
committed
All options not enclosed in quotes but taken separately
Java folder should be used as working directory
1 parent 0258b9c commit 9587c16

1 file changed

Lines changed: 36 additions & 31 deletions

File tree

src/universalJavaApplicationStub

Lines changed: 36 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,24 @@ 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+
pwd
183+
180184
# execute Java and set
181185
# - classpath
182186
# - dock icon
@@ -186,23 +190,24 @@ elif [ -x "$JAVACMD" ]; then
186190
# - main class
187191
# - JVM arguments
188192
exec "$JAVACMD" \
189-
-cp "${JVMClasspath}" \
190-
-Xdock:icon="$PROGDIR/../Resources/${CFBundleIconFile}" \
193+
-cp "./*" \
194+
-Xdock:icon="$ResourcesFolder/${CFBundleIconFile}" \
191195
-Xdock:name="${CFBundleName}" \
192-
${JVMOptions:+"$JVMOptions" }\
193-
${JVMDefaultOptions:+"$JVMDefaultOptions" }\
196+
${JVMOptions:+$JVMOptions }\
197+
${JVMDefaultOptions:+$JVMDefaultOptions }\
194198
"${JVMMainClass}"\
195-
${JVMArguments:+"$JVMArguments"}
196-
197-
199+
${JVMArguments:+$JVMArguments}
200+
201+
198202
else
199203

200204
# display error message with applescript
201205
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-
206+
203207
# and open java.com
204208
open http://java.com
205-
209+
206210
# exit with error
207211
exit 1
208-
fi
212+
fi
213+

0 commit comments

Comments
 (0)