For some time now, our Java application has came pre bundled with a JRE on Windows. We have a little launcher app written in C that make the application use our pre bundled JRE. Now with Apple’s crusade to slowly kill Java we have decided that it would be prudent to something similar on OSX. What would be the best way to use a pre bundled JRE on OSX?
Share
Even if I find it a bad idea (see below) you could just bundle a JVM like OpenJDK and then start your application with a small script calling your
javaexecutable.Notice: I have no idea if redistributing a JVM is allowed (legal), you should check the agreement before downloading
The first problem you will have is that at the moment there is just Apple’s version or Oracle Java 7u6 Mac OS X Port Developer Preview Release (which is just a preview). (e.g., http://jdk7.java.net/macportpreview/). This will change in the future when Apple will stop supplying its own version. So at the moment you are stuck with a preview running on Lion only. But I will show you an example.
Download the installer, mount the disk image, right click on the plugin, choose “Show package content” extract the
Homefolder, it contains the JREYou can then check with
I would then rename
Homein something likejreIf you package this folder with your application you will just have to include a small script with
To be able to build an application you will need an
applicationname.app/Contents/MacOSfolder containing you script (which should be namedapplicationname).Now it seems that you need the use absolute paths in these scripts
I suppose that there is a better solution to build a Mac OS X application bundle but I’m not an expert. This example was just to show that it can work.
Summarizing:
Check if it is allowed to redistribute the JRE (and check which are the conditions)
I would not do it since you will have to keep it updated and update your application every time there is JRE security update
As a user I would trust more Oracle than a random developer (nothing personal 🙂 to get a JRE