Jorl17 / jar2app

Convert any Java jar to a Mac OS X .App bundle. No external tools needed, no funky parameters, it just works.
GNU General Public License v2.0
418 stars 56 forks source link

"unable to load java runtime environment" #50

Open ddyer0 opened 3 years ago

ddyer0 commented 3 years ago

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.

Lucina commented 3 years ago

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

ddyer0 commented 3 years ago

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.

Lucina commented 3 years ago

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.

ddyer0 commented 3 years ago

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

Lucina commented 3 years ago

It's part of JDK 14+.

ddyer0 commented 3 years ago

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.

Lucina commented 3 years ago

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.

ddyer0 commented 3 years ago

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

Lucina commented 3 years ago

As I said, the name is jpackage.

ddyer0 commented 3 years ago

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.

zbm8121 commented 3 years ago

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...

Lucina commented 3 years ago

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"

833M0L3 commented 3 years ago

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.

ddyer0 commented 3 years ago

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.

Lucina commented 3 years ago

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.

833M0L3 commented 3 years ago

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 :)