1

I have written JavaFX app with Maven, now I want to convert it to executables. I was successful at generating .exe file for Windows using launch4j-maven-plugin, for mac I'm using appbundle-maven-plugin, it generates .app, but it doesn't work (for M1), saying JRELoadError, I think it's because of my cpu architecture as I'm not using x86 one, I've tried with few versions of jdk, including one that I use to launch it in IntelliJ.

So my complete question is this: How to get M1 mac compatible .app from Java GUI Maven project? (I prefer to have as a Maven plugin if possible).

Sandro J
  • 508
  • 3
  • 11
  • And this is the exact problem with creating .exe files and such, and the whole reason that Java favors the creation of executable jar files. – Hovercraft Full Of Eels Jan 17 '22 at 21:43
  • It's possible that the "launcher" (or app entry point) isn't compatible. This tends to be pre-compiled and just copied as part of the build phase. You might consider looking at [Convert Java application to Mac OS X app](https://stackoverflow.com/questions/11037693/convert-java-application-to-mac-os-x-app) (this is some what dated by might give you some direction) – MadProgrammer Jan 17 '22 at 22:08
  • The above link out to [libgdx /packr](https://github.com/libgdx/packr); [jar2app](https://github.com/Jorl17/jar2app); [javapackager](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html)(?); [Packaging Overview](https://docs.oracle.com/en/java/javase/14/jpackage/packaging-overview.html) – MadProgrammer Jan 17 '22 at 22:09
  • There seems to have been some discussion on it earlier last year, https://sourceforge.net/p/launch4j/discussion/332683/thread/7722b7289c/?limit=25, might be worth following up – MadProgrammer Jan 17 '22 at 22:13
  • I've developed a very basic maven plugin for this: https://github.com/sandrojologua/jar2app-maven-plugin – Sandro J Feb 27 '22 at 14:10
  • Modern tooling: [*JEP 282: jlink: The Java Linker*](https://openjdk.org/jeps/282) and [*JEP 392: Packaging Tool*](https://openjdk.org/jeps/392). Learn the [*Java Platform Module System*](https://en.wikipedia.org/wiki/Java_Platform_Module_System) – Basil Bourque Mar 30 '23 at 19:59

1 Answers1

0

You could earn yourself a few bonus points by giving this https://github.com/dlemmermann/JPackageScriptFX little framework a try. I don't have an M1 Mac, so I cannot try it myself but in principle this should work with maybe a few tweaks. You may have to upgrade to the latest EA builds of Java 18 and also JavaFX 18 because there have been some recent bug fixes.

Disclaimer: I am biased because I developed this framework together with Dirk.

mipa
  • 10,369
  • 2
  • 16
  • 35
  • looks good, but how can I build an dmg using Maven with this? – kerner1000 Feb 24 '22 at 15:25
  • In jpackagefx-main/build_app_mac.sh set INSTALLER_TYPE to dmg and build again. – mipa Feb 24 '22 at 16:27
  • I don't understand how to use this. Do I just need to invoke the script inside my maven project or is there a maven plugin that I can use? – kerner1000 Feb 24 '22 at 16:34
  • The project example contains all you need. It uses maven + some scripts + jpackage/jlink/jdeps to perform the job. There is no specific plugin needed besides the standard maven plugins. The Readme describes it all. – mipa Feb 24 '22 at 17:55