6

I just installed macOS High Sierra (10.13) and am attempting to update a tutorial I wrote that shows how to packaging a Java Swing application (executable JAR) into a macOS installer.

The tutorial's steps worked fine on macOS Serra (10.12).

Now the javapackager command crashes out with:

ERROR: File Not Found. (-43) on file: /var/folders/c1/hkb.../images/ShowTime/.VolumeIcon.icns

System info:

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)

Simplified steps to reproduce:

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

Full error:

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)

Full tutorial and steps: Mac Java! | commands.txt

The error occurs whether I supply an icon file or not. Any ideas on how to fix it?

Dem Pilafian
  • 5,625
  • 6
  • 39
  • 67
  • 1
    Looks like you are getting this error when using the new Java 9. Does it also give this error when using Java 8? Java 9 was released recently, I wouldn't be surprised if the something in packaging is broken in the new Java 9. – Saeid Nourian Oct 03 '17 at 19:41
  • The `javapackager` command worked with **Java 9** on **Sierra (10.2)** before upgrading to **High Sierra (10.13)**. The error started after upgrading to **High Sierra (10.13)**. Just to be safe, I reinstalled **Java 9**, but the error remained. – Dem Pilafian Oct 03 '17 at 20:29
  • "Checked with JDK 9 in MAC OS X 10.12.6 and could confirm the issue." See: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8188763 – Dem Pilafian Oct 04 '17 at 17:24
  • 1
    I am using `javapackager` with JDK 9.0.1 downloaded from the Oracle site @ http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html and don't get this error. I suspect it is a problem with the JDK build. – GabeV Oct 23 '17 at 05:30
  • *@GabeV*, I upgraded to **build 9.0.1+11** but am still encountering the error. Did you use the above `Simplified steps to reproduce`? I'd really like to find a way to modify the steps to workaround this issue (Oracle currently has the bug slated for resolution in Java 10... in 2021?). – Dem Pilafian Oct 23 '17 at 21:32
  • 1
    @DemPilafian Just tried it and did get the error. I think the difference is I was using `-native image` in my command, not `dmg`. I do end up getting the DMG on my desktop with the ShowTime.app and link to the Applications folder. I copied the app and ran it and it works. I suppose a workaround could be to run `-native image`, which will generate the .app file, and then you can create the DMG separately. I would bet there are utils out there to do that. – GabeV Oct 23 '17 at 21:55
  • *@GabeV*, Thanks, that was it... `dmg` is broken but `image` works, and it seems that `pkg` also works and produces a **.pkg** installer -- different from a **.dmg** file but still a desired result. (If you turn your comment into an answer, I'll mark it as the solution.) – Dem Pilafian Oct 24 '17 at 17:07
  • 1
    @DemPilafian I have same error on OS X 10.13 with JDK 8 (1.8.0_152). PKG created successful, but no DMG output with javafx-gradle-plugin. – DaddyRatel Oct 30 '17 at 18:02

1 Answers1

3

As GabeV commented, the -native dmg option is broken but -native image works.

Bug report:
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8188763

Fortunately, the -native pkg option also works. It produces a .pkg installer file instead of a .dmg disk image, but an installer file is a desired result for many situations.

New steps with pkg workaround:

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

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

Update (December 4, 2017):
Apparently the problem is related to a bug of not detecting the new Apple File System (APFS) for macOS 10.3 (High Sierra). See: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8190758

Dem Pilafian
  • 5,625
  • 6
  • 39
  • 67