How to create a mac universal binary with bundled JRE?

743 Views Asked by At

I am creating a JAVA desktop app for Mac computers, using jpackage to bundle the desired JRE into the app and finally shipping a .app to the customers.

With the new m1 apple arm silicon computers I do not want to create different apps for each processor architecture with the right JRE (intel & arm) but create one single universal binary app that launches the Intel JRE on Intel computers and the Arm JRE on Arm computers. I know this is possible somehow.

I tried to create two .apps and use the lipo tool from the mac command line, but this doesn't really work.

Any suggestions how to proceed?

1

There are 1 best solutions below

2
Christopher Bruno On

I took the Zulu Intel and arm JRE (not JDK) builds and lipo'ed the binaries. You can run the script using your generated JRE bundle (you would just need to run jpackage on an Intel and ARM computer to get the appropriate runtimes for each architecture ).

Github repo:

https://github.com/ChristopherBruno78/universal_jre

Tested on intel and arm macOS 13 Ventura.