I have a somewhat out of date 10.13.2 machine. I ran the latest build of jpackage to create a dmg. The dmg was created successfully, but when I launched it, it didn't run. A pkg package created from the same application installed and ran with no problems.
I then reran jpackage to recreate the dmg file. I got the following warning message:
Exec failed with code 2 command [[/usr/bin/SetFile, -a, C, /var/folders/hc/2y60r6ms6dl5h9r109m_fs940000gn/T/jdk.jpackage18434630668362704939/images/myapp] in unspecified directory output: ERROR: Unexpected Error. (-50) on file: /var/folders/hc/2y60r6ms6dl5h9r109m_fs940000gn/T/jdk.jpackage18434630668362704939/images/myapp
In spite of that warning, the dmg file was created and this time it ran.
I then rebooted my system and now everything runs with no problems. I can build and run either a dmg or a pkg with no warnings.
I then reran jpackage to recreate the dmg file. I got the following warning message:
Exec failed with code 2 command [[/usr/bin/SetFile, -a, C, /var/folders/hc/2y60r6ms6dl5h9r109m_fs940000gn/T/jdk.jpackage18434630668362704939/images/myapp] in unspecified directory output: ERROR: Unexpected Error. (-50) on file: /var/folders/hc/2y60r6ms6dl5h9r109m_fs940000gn/T/jdk.jpackage18434630668362704939/images/myapp
In spite of that warning, the dmg file was created and this time it ran.
I then rebooted my system and now everything runs with no problems. I can build and run either a dmg or a pkg with no warnings.