简体   繁体   English

手动在MacOS上为Java 7 jar文件创建Bundle

[英]Creating Bundle for Java 7 jar file on MacOS manually

I'm reading through documentation and have created an app bundle (using Finder, Terminal and TextEdit) as follows: 我正在阅读文档,并创建了一个应用程序包(使用Finder,Terminal和TextEdit),如下所示:

GUITest.app/
    Contents/
        Info.plist
        PkgInfo
        MacOS/
            JavaAppLauncher
        Resources/
            GenericJavaApp.icns
            Java/
                gui.jar

However when I try double clicking on the finder, the icon has a "no entry" sign on it, and when I double-click, I get: The application "GUITest" can't be opened. -10810 但是,当我尝试双击取景器时,图标上面有一个“无条目”标志,当我双击时,我得到: The application "GUITest" can't be opened. -10810 The application "GUITest" can't be opened. -10810

If I try kicking off the JavaAppLauncher manually: ./GUITest.app/Contents/MacOS/JavaAppLauncher I get a dialog with " JRELoadError " 如果我尝试手动./GUITest.app/Contents/MacOS/JavaAppLauncher JavaAppLauncher: ./GUITest.app/Contents/MacOS/JavaAppLauncher我得到一个带有“ JRELoadError ”的对话框

The Info.plist seems pretty straightforward. Info.plist似乎非常简单。 PkgInfo is just AAPL???? PkgInfo只是AAPL???? and the JavaAppLauncher is from the http://java.net/projects/appbundler/downloads/download/appbundler-1.0.jar JavaAppLauncher来自http://java.net/projects/appbundler/downloads/download/appbundler-1.0.jar

Could these problems be down to a bad Info.plist or something else? 这些问题可能归结为一个糟糕的Info.plist或其他什么?

Here is the Info.plist: 这是Info.plist:

<?xml version="1.0" ?>
<!DOCTYPE plist PUBLIC "-//Apple//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>JavaAppLauncher</string>
    <key>CFBundleIconFile</key>
    <string>GenericApp.icns</string>
    <key>CFBundleIdentifier</key>
    <string>gui.GUITest</string>
    <key>CFBundleDisplayName</key>
    <string>GUITest</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>GUITest</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>NSHumanReadableCopyright</key>
    <string>©xirt, 2014</string>
    <key>LSApplicationCategoryType</key>
    <string>public.app-category.developer-tools</string>
    <key>JVMRuntime</key>
    <string>jdk1.7.0_17.jdk</string>
    <key>JVMMainClassName</key>
    <string>main.GUITest</string>
    <key>JVMOptions</key>
    <array>
    </array>
    <key>JVMArguments</key>
    <array>
    </array>
  </dict>
</plist>

Note: the no entry sign was removed by removing the com.apple.quarantine extended attribute: xattr -d com.apple.quarantine JavaAppLauncher But the problem still occurs: 注意:通过删除com.apple.quarantine扩展属性删除了无条目符号: xattr -d com.apple.quarantine JavaAppLauncher但问题仍然存在:

$ open ./GUITest.app
LSOpenURLsWithRole() failed with error -10810 for the file /Users/.../GUITest.app.

The error above can be re-created if the process simply fails. 如果进程完全失败,则可以重新创建上述错误。 For example, replacing JavaAppLauncher with the following shell script reproduces the problem: 例如,使用以下shell脚本替换JavaAppLauncher会重现该问题:

#!/bin/bash
return -1

So, I suppose I have to look at why JavaAppLauncher fails... 所以,我想我必须看看为什么JavaAppLauncher失败......

Okay - it took some figuring but there were a number of issues. 好的 - 它需要一些计算,但有一些问题。 Ultimately, I recompiled my own JavaAppLauncher from the app bundler source and stepped through it in Xcode (so much for helpful documentation!). 最后,我从应用程序捆绑器源重新编译了我自己的JavaAppLauncher,并在Xcode中逐步完成了它(非常有用的文档!)。 https://java.net/projects/appbundler https://java.net/projects/appbundler

  1. The JDK reference seemed to be wrong, so removing the JVM Runtime key <key>JVMRuntime</key> <string>jdk1.7.0_17.jdk</string> helped here. JDK引用似乎是错误的,因此在<key>JVMRuntime</key> <string>jdk1.7.0_17.jdk</string>删除JVM运行时键<key>JVMRuntime</key> <string>jdk1.7.0_17.jdk</string>

  2. The Java directory needed to be at the Contents level, not Resources. Java目录需要位于内容级别,而不是资源。

     GUITest.app/ Contents/ Info.plist PkgInfo MacOS/ JavaAppLauncher Resources/ GenericJavaApp.icns Java/ gui.jar 
  3. After fixing these issues, despite two separate applications showing identical diff s, one worked while the other showed error -1080 (!). 解决了这些问题之后,尽管有两个独立的应用程序显示相同的diff ,但一个工作,而另一个显示错误-1080 (!)。 Removing the extended attributes solved the problem: xattr -lr GUITest.app . 删除扩展属性解决了问题: xattr -lr GUITest.app

see also the java.net page on Packaging: http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html 另见打包的java.net页面: http//docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM