0

I am building a Java 9 application for MacOS using Javapackager, via ant.

The build process succeeds without complaint, but the resulting application does not launch. However, when I run the executable within the generated application bundle, it does work. The problem, therefore, seems to be that launchd cannot find or launch that executable.

When I open the executable, I see:

The application cannot be opened for an unexpected reason, error=Error Domain=NSOSStatusErrorDomain Code=-10810 "kLSUnknownErr: Unexpected internal error" UserInfo={_LSFunction=_LSLaunchWithRunningboard, _LSLine=2732, NSUnderlyingError=0x600003f40630 {Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x600003f404b0 {Error Domain=NSPOSIXErrorDomain Code=21 "Is a directory" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}}}

The fx:deploy task looks like this:

<fx:deploy width="300" height="250"
           nativeBundles="image"
           outdir="Platforms/Macintosh/dist"
           mainClass="<classname>"
           outfile="<applicationname>">
    <fx:application refId="<appid>"/>
    <fx:resources refid="<resources>"/>
    <fx:info title="<appname>" vendor="<myname>"/>
</fx:deploy>

where the <parameters> are specified, of course.

Here is the equivalent (at least in the sense that it produces the same error) javapackager command line:

javapackager -deploy -native image 
    -outdir Platforms/Macintosh/dist -outfile appname 
    -srcdir Platforms/Java/dist -srcfiles jarfilename 
    -appclass classname 
    -name "appname" -title "appname demo" 
    -nosign

jarfilename and classname are set correctly, that is jarfilename is the name of an existing jar file, and classname is the name of a class within that jar file. And again, the executable in the generated application bundle runs with the expected outcome.

appname is the name of the application that I want to create. No object (folder or file) with that name exists in the output directory.

I am missing something, but I am unsure of what. Any advice?

Thanks in advance.

dbp
  • 91
  • 1
  • 12
  • Sounds like you are specifying a directory name where a filename is expected. – Jim Garrison Nov 29 '22 at 01:24
  • Have you bundled a jre with your application ? If not, are you sure that current jre on your hosting machine has the right version compared to the required version by your app ? (e.g. if your default jre is 8 and your app is compiled with java 11, it won't launch). – lvr123 Dec 08 '22 at 20:20
  • Other question, have you tried your build in another environment ? e.g. running it on a Linux virtual machine ? – lvr123 Dec 08 '22 at 20:21
  • As I said in the question, when I run the executable created within the bundle, the Java application launches and behaves as expected. It is not a Java incompatability issue. – dbp Dec 09 '22 at 00:48
  • javapackager builds an application suitable for the platform on which it is run. That is, running it on a Linux box would produce a Linux application, which is not what I want. – dbp Dec 09 '22 at 00:49

1 Answers1

0

The error you are having is because you are trying to create a file, in this case it is either appname or jarfilename but that path has been already created as a folder, probably by a previous command.

Maybe you can try to list files and folders in the folder where this command is running and check if this is correct

  • This is not correct. As I said in the question, the error is not happening during the execution of javapackager, but during the launch of the executable that javapackager produces. – dbp Dec 04 '22 at 22:12
  • The cause is the same one: of your derived products is creating the file where a folder exists, probably you are running it in a different folder to the one you are thinking of, or one of those commands is running in a different folder you are not using directly – Raul Lapeira Herrero Dec 05 '22 at 08:06
  • The "derived product" is an application which does not create files or folders. And as I said in the question, the executable within the application bundle executes correctly. – dbp Dec 05 '22 at 22:01
  • the output "Launchd job spawn failed" disagrees with that statement. But ok. – Raul Lapeira Herrero Dec 06 '22 at 17:59
  • Which statement? It is true that launchd fails to spawn the job, and it is true that the executable runs correctly. When you double click on an application, launchd runs, looks inside the application bundle for the executable (specified in Info.plist) and then launches it. If I take launchd out of the picture, the executable runs correctly. – dbp Dec 06 '22 at 21:45