Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"unable to load java runtime environment" #50

Open
ddyer0 opened this issue Jan 17, 2021 · 16 comments
Open

"unable to load java runtime environment" #50

ddyer0 opened this issue Jan 17, 2021 · 16 comments

Comments

@ddyer0
Copy link

ddyer0 commented Jan 17, 2021

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
Copy link
Contributor

Lucina commented Jan 17, 2021

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
Copy link
Author

ddyer0 commented Jan 17, 2021

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
Copy link
Contributor

Lucina commented Jan 18, 2021

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
Copy link
Author

ddyer0 commented Jan 18, 2021

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

@Lucina
Copy link
Contributor

Lucina commented Jan 18, 2021

It's part of JDK 14+.

@ddyer0
Copy link
Author

ddyer0 commented Jan 18, 2021

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
Copy link
Contributor

Lucina commented Jan 18, 2021

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
Copy link
Author

ddyer0 commented Jan 18, 2021

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

@Lucina
Copy link
Contributor

Lucina commented Jan 18, 2021

As I said, the name is jpackage.

@ddyer0
Copy link
Author

ddyer0 commented Jan 19, 2021

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
Copy link

zbm8121 commented Jan 21, 2021

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
Copy link
Contributor

Lucina commented Jan 21, 2021

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
Copy link

833M0L3 commented Jan 24, 2021

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
Copy link
Author

ddyer0 commented Jan 24, 2021

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
Copy link
Contributor

Lucina commented Jan 24, 2021

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
Copy link

833M0L3 commented Jan 25, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants