@@ -63,23 +63,41 @@ while [ -h "$PRG" ]; do
6363 fi
6464done
6565
66+ # set the directory abspath of the current shell script
6667PROGDIR=` dirname " $PRG " `
6768
6869
6970
7071
7172#
72- # read Info.plist and extract JVM options
73+ # set files and folders
7374# ###########################################
7475
76+ # the base path of the app package
77+ cd " $PROGDIR " /../../
78+ AppPackageFolder=` pwd`
79+
7580# set Apple's Java folder
76- AppleJavaFolder=" $PROGDIR /../Resources/Java/"
81+ AppleJavaFolder=" ${AppPackageFolder} " /Contents/Resources/Java
82+
83+ # set Apple's Resources folder
84+ AppleResourcesFolder=" ${AppPackageFolder} " /Contents/Resources
7785
7886# set Oracle's Java folder
79- OracleJavaFolder=" $PROGDIR /../Java/"
87+ OracleJavaFolder=" ${AppPackageFolder} " /Contents/Java
88+
89+ # set Oracle's Resources folder
90+ OracleResourcesFolder=" ${AppPackageFolder} " /Contents/Resources
8091
8192# set path to Info.plist in bundle
82- InfoPlistFile=" $PROGDIR /../Info.plist"
93+ InfoPlistFile=" ${AppPackageFolder} " /Contents/Info.plist
94+
95+
96+
97+
98+ #
99+ # read Info.plist and extract JVM options
100+ # ###########################################
83101
84102
85103# read the program name from CFBundleName
@@ -92,9 +110,27 @@ CFBundleIconFile=`/usr/libexec/PlistBuddy -c "print :CFBundleIconFile" ${InfoPli
92110# read Info.plist in Apple style
93111if [ -d " ${AppleJavaFolder} " ]; then
94112
95- # set working directory
113+ # read the Java WorkingDirectory
114+ JVMWorkDir=` /usr/libexec/PlistBuddy -c " print :Java:WorkingDirectory" ${InfoPlistFile} 2> /dev/null | xargs`
115+
116+ # set Working Directory based upon Plist info
117+ if [ " ${JVMWorkDir} " == " \$ JAVAROOT" ]; then
118+ WorkingDirectory=" ${AppleJavaFolder} "
119+
120+ elif [ " ${JVMWorkDir} " == " \$ APP_PACKAGE" ]; then
121+ WorkingDirectory=" ${AppPackageFolder} "
122+
123+ elif [ " ${JVMWorkDir} " == " \$ USER_HOME" ]; then
124+ WorkingDirectory=" ~"
125+
126+ else
127+ # root is the standard WorkingDirectory when the script is started
128+ WorkingDirectory=" /"
129+ fi
130+
131+ # set Java and Resources folder
96132 JavaFolder=" ${AppleJavaFolder} "
97- ResourcesFolder=" .. "
133+ ResourcesFolder=" ${AppleResourcesFolder} "
98134
99135 # read the MainClass name
100136 JVMMainClass=` /usr/libexec/PlistBuddy -c " print :Java:MainClass" ${InfoPlistFile} 2> /dev/null`
@@ -112,9 +148,10 @@ if [ -d "${AppleJavaFolder}" ]; then
112148# read Info.plist in Oracle style
113149elif [ -d " ${OracleJavaFolder} " ]; then
114150
115- # set working directory
151+ # set Working Directory and Java and Resources folder
116152 JavaFolder=" ${OracleJavaFolder} "
117- ResourcesFolder=" ../Resources"
153+ ResourcesFolder=" ${OracleResourcesFolder} "
154+ WorkingDirectory=" ${OracleJavaFolder} "
118155
119156 # read the MainClass name
120157 JVMMainClass=` /usr/libexec/PlistBuddy -c " print :JVMMainClassName" ${InfoPlistFile} 2> /dev/null`
@@ -178,7 +215,8 @@ elif [ -x "$JAVACMD" ]; then
178215 # enable drag&drop to the dock icon
179216 export CFProcessPath=" $0 "
180217
181- cd " $JavaFolder "
218+ # change to Working Directory based upon Apple/Oracle Plist info
219+ cd " ${WorkingDirectory} "
182220
183221 # execute Java and set
184222 # - classpath
@@ -189,8 +227,8 @@ elif [ -x "$JAVACMD" ]; then
189227 # - main class
190228 # - JVM arguments
191229 exec " $JAVACMD " \
192- -cp " . /*" \
193- -Xdock:icon=" $ResourcesFolder /${CFBundleIconFile} " \
230+ -cp " ${JavaFolder} /*" \
231+ -Xdock:icon=" ${ ResourcesFolder} /${CFBundleIconFile} " \
194232 -Xdock:name=" ${CFBundleName} " \
195233 ${JVMOptions: +$JVMOptions } \
196234 ${JVMDefaultOptions: +$JVMDefaultOptions } \
0 commit comments