24

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?

Tomas Andrle
  • 13,132
  • 15
  • 75
  • 92
  • Just curious, where did you learn that Mac OS X won't be including any JRE? – david van brink Jan 18 '11 at 21:59
  • Java 6 SE will be available on OS X 10.7: http://www.apple.com/pr/library/2010/11/12openjdk.html – mipadi Jan 18 '11 at 22:18
  • @mipadi: I think the key word is "available", as opposed to "included in default install". Perhaps even Apple is leaving their options open for 10.7. The fact is, though, that a program that requires Java is not eligible for the Mac App Store. Java is going to become an optional download sooner or later, first from Apple, then from Oracle. – Tomas Andrle Jan 19 '11 at 21:21

3 Answers3

12

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 (e.g., 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!

Matt Solnit
  • 32,152
  • 8
  • 53
  • 57
  • 3
    You don't have to distribute your app through the app store. If you do, you can bundle a JRE with it, and release it under the GPL as well. (This is more directed to the OP than Matt Solnit, but I thought it was relevant to comment here.) – mipadi Jan 18 '11 at 22:13
  • @unhillbilly you're right, it's my mistake. Lion will include Java 6, but Java 7 will be a separate download from Oracle. However, this doesn't change the situation for the App Store. – Matt Solnit Jan 19 '11 at 16:53
  • @Matt yeah, it doesn't look good for App Store. Thanks for the IKVM info -- very interesting. I wonder if it would run afoul of Oracle as Dalvik/Android has? – David J. Liszewski Jan 19 '11 at 19:43
  • @unhillbilly: If you read it at face value, that link doesn't say Java will be part of Lion — just that Java 6 will "be available from Apple" even after Lion is released. Final Cut Pro will also be available from Apple for Lion, but it is not part of Lion either. – Chuck Jan 19 '11 at 21:51
  • Wow. Just tried it on my app. In a few minutes I got as far as actually getting some init logging output (through log4j). It then failed to load ikvm-native for some JNI stuff. After I get some sleep, I'll investigate more. It definitely looks promising. – Tomas Andrle Jan 19 '11 at 22:29
  • Oracle has now public instructions on how to publish a Java application with an enclosed JRE to the Apple App store. – Thorbjørn Ravn Andersen Apr 14 '13 at 14:17
4

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.

stippi
  • 855
  • 8
  • 15
-2

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.

  • 1
    I'm well aware of the Apple/Oracle situation. That doesn't solve my problem. Apart from somehow compiling into native code, packaging a private JRE is the only way to get a Java app into the Mac App Store. The rules say that an app must have no dependencies on optional 3rd party components. So unfortunately, I cannot "just tell the user". – Tomas Andrle Jan 16 '11 at 00:24
  • 1
    You currently cannot tell anyone — and will *never* be able to tell App Store users — to "download and install the OpenJDK JRE for Mac OS X," so this doesn't really answer the question at all. – Chuck Jan 16 '11 at 21:48