appbundler应用程序可以使用应用程序捆绑包中的嵌入式Java 7 JRE,也可以使用安装在
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home其中的Java 7 JRE (Web浏览器插件使用的Java 7 JRE
)。他们不能使用安装在该目录下的
JDK
/Library/Java/JavaVirtualMachines(或其他任何地方),并且绝对不能使用Java 6。
但是,您 可以
做的是不使用
appbundler,而是手动构建捆绑包,主要的可执行文件是运行
java命令行工具的shell脚本
JAVA_HOME(
/Library/InternetPlug-Ins如果
JAVA_HOME未设置,则退回到JRE )。这样的脚本将能够支持Java 6和7。
您将使用如下所示的内容
YourApp.app/Contents/MacOS/YourApp:
#!/bin/shPRG=$0while [ -h "$PRG" ]; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '^.*-> (.*)$' 2>/dev/null` if expr "$link" : '^/' 2> /dev/null >/dev/null; then PRG="$link" else PRG="`dirname "$PRG"`/$link" fidoneprogdir=`dirname "$PRG"`if [ -n "$JAVA_HOME" ]; then JAVACMD="$JAVA_HOME/bin/java"elif [ -x /usr/libexec/java_home ]; then JAVACMD="`/usr/libexec/java_home`/bin/java"else JAVACMD="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java"fiexec "$JAVACMD" -classpath "$progdir/../Resources/Jars/*" -Dapple.laf.useScreenMenuBar=true my.pkg.MainClass
然后将您应用程序的JAR文件放在中
YourApp.app/Contents/Resources/Jars,将图标放在中
YourApp.app/Contents/Resources/icon.icns,并将以下内容放在中
YourApp.app/Contents/Info.plist:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict> <key>CFBundleDevelopmentRegion</key> <string>English</string> <key>CFBundleExecutable</key> <string>YourApp</string><!-- relative to Contents/MacOS --> <key>CFBundleGetInfoString</key> <string>My clever application</string> <key>CFBundleIconFile</key> <string>icon.icns</string><!-- relative to Contents/Resources --> <key>CFBundleInfoDictionaryVersion</key> <string>8.0</string> <key>CFBundleName</key> <string>YourApp</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>8.0</string></dict></plist>
有关完整的详细信息,请参见GATE
Developer启动器。不过请注意,这是一个较为复杂的情况,因为
.app脚本委托给另一个脚本,该脚本又从
.app捆绑包外部的位置加载JAR文件。然而,原理保持不变。



