jar2app icon indicating copy to clipboard operation
jar2app copied to clipboard

"unable to load java runtime environment"

Open ddyer0 opened this issue 4 years ago • 16 comments

I've jumped through most of the hoops to get my app into the apple app store; it works fine if java is installed and jar2app doesn't specify a jvm. However, it seems unlikely that apple will accept this. If I add a jvm with the -j, the .app no longer launches with the quoted. "unable to load java runtime environment"

I see traffic in other threads about the same problem, but no clear solutions.

ddyer0 avatar Jan 17 '21 02:01 ddyer0

As far as I know it's down to stub support. You could fork an extant stub to support detecting / executing your bundled jvm.

Lucina avatar Jan 17 '21 21:01 Lucina

Yea, it's all in the stub. I simply substituted "universalJavaApplicationStub" for JavaApplicationLauncher and that works great, except it's not acceptable to the app store because a raw shell script isn't signed or signable.

ddyer0 avatar Jan 17 '21 22:01 ddyer0

If it’s a recent Java version, have you tried jpackage

It’s like JavaFX javapackager from Java 10, capable of producing trimmed app images. I don’t know if it supports apps that don’t use the module system, but this should be a viable (and better) solution for producing apps meant to be distributed to the App Store.

Lucina avatar Jan 18 '21 00:01 Lucina

jpackage sounds like the long term solution, but for now I can't even find a place to download it.

ddyer0 avatar Jan 18 '21 01:01 ddyer0

It's part of JDK 14+.

Lucina avatar Jan 18 '21 04:01 Lucina

I finally found it - it's well concealed on macs. There's no binary called jpackager, though there is a brother of "java" called javapackager which doesn't run; and there's one in $JAVA_HOME/bin/jpackage which seems to be the real deal.

ddyer0 avatar Jan 18 '21 07:01 ddyer0

It's not concealed. It's where it should be expected. The bin folder of the jdk. If your $PATH is set correctly, it's just a matter of invoking it by name.

Lucina avatar Jan 18 '21 10:01 Lucina

The expected name is "jpackager" which is nowhere to be found on Macs. It's there on PCs.

ddyer0 avatar Jan 18 '21 18:01 ddyer0

As I said, the name is jpackage.

Lucina avatar Jan 18 '21 21:01 Lucina

After much screwing around with jpackage, I think I've got it to work. There are residual problems with code signing and info.plist, which I've solved by manually editing the info.plist and re-signing all the .dylibs and helper apps. So I recommend the jpackage route over jar2app and also over universalJavaApplicationLauncher, which also came very close to working.

ddyer0 avatar Jan 19 '21 01:01 ddyer0

Does anyone know if there is an option in jpackage that mimics the -o option in jar2app? The one that allows the app to use the macos menu bar...

zbm8121 avatar Jan 21 '21 05:01 zbm8121

Does anyone know if there is an option in jpackage that mimics the -o option in jar2app? The one that allows the app to use the macos menu bar...

Add --java-options "-Dapple.laf.useScreenMenuBar=true"

Lucina avatar Jan 21 '21 08:01 Lucina

I had a similar issue and I fixed this by replacing the JavaAppLauncher of jar2app. You can get the working JavaAppLauncher from here https://github.com/tofi86/universalJavaApplicationStub

Go to that link and you will see UniversalJavaStub inside the src folder. Take that file and rename it to JavaAppLauncher and use it to replace the old one that the jar2app has.

833M0L3 avatar Jan 24 '21 17:01 833M0L3

Directly replacing JavaAppLauncher with universalApplicationStub fixes some problems, but because universalApplicationStub is a shell script, it can't be signed and can never get into the app store. If it were rewritten as a native binary, or if someone wrote a csh variant that took arguments from info.plist, that could be fixed. However, using jpackage is a more enduring solution - it will get support from oracle to keep it running despite apple.

ddyer0 avatar Jan 24 '21 19:01 ddyer0

I had a similar issue and I fixed this by replacing the JavaAppLauncher of jar2app. You can get the working JavaAppLauncher from here https://github.com/tofi86/universalJavaApplicationStub

Go to that link and you will see UniversalJavaStub inside the src folder. Take that file and rename it to JavaAppLauncher and use it to replace the old one that the jar2app has.

You realize they've quite literally said they've tried this already, right? Update or not it's not an acceptable solution.

Lucina avatar Jan 24 '21 21:01 Lucina

Directly replacing JavaAppLauncher with universalApplicationStub fixes some problems, but because universalApplicationStub is a shell script, it can't be signed and can never get into the app store. If it were rewritten as a native binary, or if someone wrote a csh variant that took arguments from info.plist, that could be fixed. However, using jpackage is a more enduring solution - it will get support from oracle to keep it running despite apple.

Sorry, I didn't read the whole thing and jumped right into the commenting. It seems this whole repo is dead and the owner hasn't done anything for a long time. I did learn new things. For me, I was only trying to make a jar executable program into an app just for casual usability for myself and not to upload it on AppStore. Also, thanks for sharing the solution :)

833M0L3 avatar Jan 25 '21 04:01 833M0L3