在macOS High Sierra上使用javapackager找不到icns文件错误

时间:2017-10-01 18:04:55

标签: java macos macos-high-sierra javapackager icns

我刚刚安装了 macOS High Sierra(10.13),我正在尝试更新我编写的教程,该教程展示了如何将Java Swing应用程序(可执行JAR)打包到macOS安装程序中。

教程的步骤在 macOS Serra(10.12)上运行良好。

现在javapackager命令崩溃了:

  

错误:找不到文件。 (-43)文件:/ var / folders / c1 / hkb ... / images / ShowTime / .VolumeIcon.icns

系统信息:

Darwin Comet.local 17.0.0 Darwin Kernel Version 17.0.0: Thu Aug 24 21:48:19 PDT 2017; root:xnu-4570.1.46~2/RELEASE_X86_64 x86_64
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

重现的简化步骤:

curl --remote-name https://centerkey.com/mac/java/ShowTime.java
javac ShowTime.java
echo "Main-Class: ShowTime" > MainClass.txt
jar cmf MainClass.txt ShowTime.jar *.class
jdk=$(/usr/libexec/java_home)
$jdk/bin/javapackager -deploy -native dmg -name ShowTime \
   -srcdir . -srcfiles ShowTime.jar -appclass ShowTime \
   -outdir deploy -outfile ShowTime -v

完整错误:

Running [/usr/bin/SetFile, -c, icnC, /var/folders/c1/hkb5ph9s7l352nhr17n310vc0000gn/T/fxbundler10109585143778151656/images/ShowTime/.VolumeIcon.icns]
ERROR: File Not Found. (-43)  on file: /var/folders/c1/hkb5ph9s7l352nhr17n310vc0000gn/T/fxbundler10109585143778151656/images/ShowTime/.VolumeIcon.icns 
java.io.IOException: Exec failed with code 2 command [[/usr/bin/SetFile, -c, icnC, /var/folders/c1/hkb5ph9s7l352nhr17n310vc0000gn/T/fxbundler10109585143778151656/images/ShowTime/.VolumeIcon.icns] in unspecified directory
    at jdk.packager/com.oracle.tools.packager.IOUtils.exec(IOUtils.java:169)
    at jdk.packager/com.oracle.tools.packager.IOUtils.exec(IOUtils.java:142)
    at jdk.packager/com.oracle.tools.packager.IOUtils.exec(IOUtils.java:136)
    at jdk.packager/com.oracle.tools.packager.mac.MacDmgBundler.buildDMG(MacDmgBundler.java:391)
    at jdk.packager/com.oracle.tools.packager.mac.MacDmgBundler.bundle(MacDmgBundler.java:92)
    at jdk.packager/com.oracle.tools.packager.mac.MacDmgBundler.execute(MacDmgBundler.java:549)
    at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:371)
    at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:348)
    at jdk.packager/com.sun.javafx.tools.packager.Main.main(Main.java:496)
Config files are saved to /var/folders/c1/hkb5ph9s7l352nhr17n310vc0000gn/T/fxbundler10109585143778151656/macosx. Use them to customize package.
Exception in thread "main" com.sun.javafx.tools.packager.PackagerException: Error: Bundler "DMG Installer" (dmg) failed to produce a bundle.
    at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:374)
    at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:348)
    at jdk.packager/com.sun.javafx.tools.packager.Main.main(Main.java:496)

完整教程和步骤: enter image description here | Mac Java!

无论是否提供图标文件,都会发生错误。关于如何解决它的任何想法?

1 个答案:

答案 0 :(得分:3)

GabeV 评论时,-native dmg选项已损坏但-native image有效。

错误报告:
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8188763

幸运的是,-native pkg选项也有效。它会生成 .pkg 安装程序文件,而不是 .dmg 磁盘映像,但安装程序文件在许多情况下都是理想的结果。

使用 pkg 解决方法的新步骤

curl --remote-name https://centerkey.com/mac/java/ShowTime.java
javac ShowTime.java
echo "Main-Class: ShowTime" > MainClass.txt
jar cmf MainClass.txt ShowTime.jar *.class
jdk=$(/usr/libexec/java_home)
$jdk/bin/javapackager -deploy -native pkg -name ShowTime \
   -srcdir . -srcfiles ShowTime.jar -appclass ShowTime \
   -BappVersion=1.0.0 -outdir deploy -v
ls -l deploy
open deploy/ShowTime-1.0.0.pkg

文档:
https://docs.oracle.com/javase/9/tools/javapackager.htm

更新(2017年12月4日):
显然,该问题与未检测到macOS 10.3(High Sierra)的新Apple文件系统(APFS)的错误有关。请参阅:https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8190758