Open ddyer0 opened 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.
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.
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.
jpackage sounds like the long term solution, but for now I can't even find a place to download it.
It's part of JDK 14+.
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.
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.
The expected name is "jpackager" which is nowhere to be found on Macs. It's there on PCs.
As I said, the name is jpackage.
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.
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...
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"
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.
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.
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.
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 :)
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.