简体   繁体   中英

Bundling a private JRE on Mac OS X

Starting with the next version of Mac OS X, Java will no longer be included in the system and I don't want to force my customers to install it themselves. So I would like to do what I do on Windows - bundle it with my app. It also gives me some hope that it could get included in the Mac App Store.

Where can I download a Mac OS X JRE that I could include with my application? Or can I just copy the one that's installed on my Mac?

Update (4/15/2013):

As Thorbjørn helpfully pointed out, Oracle now has a solution for this. See http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html . However, I'm keeping the original content for "historical purposes", and because it was a fun research project.

Previous version (with edits):

This is a great question. I was going to respond that you are simply ahead of your time -- as you pointed out, Java is not going to be removed until the Lion release. However, this article makes it clear that using Java today is not allowed:

Apps that use deprecated or optionally installed technologies (eg, Java, [PowerPC code requiring] Rosetta) will be rejected.

At the same time, no one has announced a redistributable JRE for Mac OS X yet. I think your best bet, bearing in mind that you are forging new ground, is to check out the Mac OS X Port wiki page of the OpenJDK project. It does describe how to compile your own JDK, but it does not clearly state whether or not the resulting JDK can be "bundled" cleanly or not. I think you will have to try it and see :-(.

Also, it's not clear if the OpenJDK licensing allows this at all (IANAL). Hopefully someone else has already figured this out with regard to Linux/Windows, although of course the rules may be different for the Apple contributions.

Hope this helps. If nothing else, it's a starting point.

EDIT: I am going to throw out one additional suggestion. We now know that Mono apps can be packaged for the App Store . Furthermore, IKVM.NET is a complete implementation of Java that runs on top of Mono. You could try, in theory, to put these two pieces together and get a Java app, bundled for the App Store, that does not in fact require a JRE!

If you try this, I would love to hear how it works out :-).

EDIT 2: Unfortunately, the App Store and the GPL do not appear to be compatible (see http://www.zdnet.com/blog/open-source/no-gpl-apps-for-apples-app-store/8046 ). The OpenJDK license isn't exactly the same as the GPL, but it's pretty close (again, IANAL). Therefore, Mono & IKVM.NET may be your best bet. Good luck!

In the same web search that I found this question, I've found the these instructions from the OpenJDK project. Not having tried them myself, I cannot comment on how well they work.

Meanwhile, another, very detailled article was published by Marco Dinacci which also goes into signing and sandboxing.

Apple has joined the Sun/Oracle OpenJDK open source project last month, so Java on Apple is alive and kicking.

Just tell the user to download and install the OpenJDK JRE for Mac OSX (when it becomes available, right now it´s just source code).

And no. you cannot include "the folder that is in your mac" without permission as it is copyrighted code from Apple.

Finally, packaging a "private JRE" is a very bad practice, it will make your app bloated, andif the user ends up running several Java apps, he will end up running multiple Java VMs simultaneously which is a terrible waste of system resources.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM