Java手动将.JAR打包到.APP中

时间:2013-12-10 14:29:06

标签: java macos jar plist bundle

我在OS X上用Java编写了我的程序,我想将我的.JAR捆绑到一个可运行的.APP中,这样我就可以分发我的程序了。我正在运行OS X 10.9,我在我的机器上找不到Apple的JarBundler.app。我查看了Oracles Jar Bundler解决方案,它需要一个.plist。所以我的问题是,如何创建我需要的plist,我可以手动构建我的.app?

解决方案:

经过足够的调整后,我终于能够将我的java应用程序捆绑并以.app。

运行
   <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"     "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrefPaneIconFile</key>
<string>NotesClonerIcon.icns</string>
<key>Java</key>
<dict>
    <key>JVMVersion</key>
    <string>1.6+</string>
    <key>MainClass</key>
    <string>Notes_Cloner</string>
    <key>ClassPath</key>
    <string>$JAVAROOT/NotesCloner.jar</string>
    <key>Properties</key>
    <dict>
        <key>java.library.path</key>
        <string>$JAVAROOT/</string>
    </dict>
</dict>
<key>Properties</key>
<dict>
    <key>apple.laf.useScreenMenuBar</key>
    <string>true</string>
</dict>
<key>CFBundleExecutable</key>
<string>JavaApplicationStub</string>

    <key>CFBundleIconFile</key>
<string>NotesClonerIcon.icns</string>

<key>WorkingDirectory</key>
<string>$APP_PACKAGE/Contents/Resources/</string>

<key>CFBundleName</key>
<string>Notes Cloner Mac</string>

<key>CFBundleDisplayName</key>
<string>Notes Cloner Mac</string>

<key>NSPrefPaneIconLabel</key>
<string>Notes Cloner Preferences</string>

<key>CFBundleGetInfoString</key>
<string>Written By:Larry Wells </string>

<key>NSHumanReadableCopyright</key>
<string>Copyright © 2013, Larry Wells,All Rights Reserved.</string>

<key>CFBundleIdentifier</key>
<string>com.LarryWells.NotesClonerMac</string>

<key>CFBundleInfoDictionaryVersion</key>
<string>1.0</string>

<key>CFBundlePackageType</key>
<string>APPL</string>

<key>CFBundleShortVersionString</key>
<string>1.0.0</string>

<key>CFBundleSignature</key>
<string>????</string>

<key>CFBundleVersion</key>
<string>1.0.0</string>
</dict>
</plist>

1 个答案:

答案 0 :(得分:0)

请参阅原始帖子以获取解决方案。我只是不断尝试不同的plist键和字符串,直到最终有效。我相信我现在遇到了管理问题,因为我的程序部分不起作用。我将为这个问题创建一个新问题。