gpt4 book ai didi

java - 在 MacOS 上手动创建 Bundle for Java 7 jar 文件

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:46:36 26 4
gpt4 key购买 nike

我正在阅读文档并创建了一个应用程序包(使用 Finder、终端和 TextEdit),如下所示:

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

然而,当我尝试双击查找器时,图标上有一个“禁止输入”的标志,当我双击时,我得到:无法打开应用程序“GUITest”。 -10810

如果我尝试手动启动 JavaAppLauncher:./GUITest.app/Contents/MacOS/JavaAppLauncher 我得到了一个对话框“JRELoadError

Info.plist 看起来非常简单。PkgInfo 只是 AAPL???? 而 JavaAppLauncher 来自 http://java.net/projects/appbundler/downloads/download/appbundler-1.0.jar

这些问题是否可以归结为错误的 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>

注意:通过删除 com.apple.quarantine 扩展属性删除了禁止进入的标志:xattr -d com.apple.quarantine JavaAppLauncher但是问题还是出现了:

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

如果过程简单地失败,可以重新创建上述错误。例如,用以下 shell 脚本替换 JavaAppLauncher 会重现问题:

#!/bin/bash
return -1

所以,我想我必须看看为什么 JavaAppLauncher 失败...

最佳答案

好的 - 需要一些计算,但存在许多问题。最终,我从应用程序 bundler 源代码重新编译了我自己的 JavaAppLauncher,并在 Xcode 中逐步完成它(非常有用的文档!)。 https://java.net/projects/appbundler

  1. JDK 引用似乎有误,因此删除 JVM 运行时 key <key>JVMRuntime</key>
    <string>jdk1.7.0_17.jdk</string>
    在这里提供帮助。

  2. Java 目录需要位于目录级别,而不是资源级别。

    GUITest.app/
    Contents/
    Info.plist
    PkgInfo
    MacOS/
    JavaAppLauncher
    Resources/
    GenericJavaApp.icns
    Java/
    gui.jar
  3. 解决这些问题后,尽管两个独立的应用程序显示相同的 diff s,一个工作,而另一个显示错误 -1080 (!)。删除扩展属性解决了问题:xattr -lr GUITest.app .

另请参阅有关打包的 java.net 页面: http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html

关于java - 在 MacOS 上手动创建 Bundle for Java 7 jar 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24582806/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com