6

I have an OS X objective-c app which programmatically invokes the Java command to run a Java program.

If I'm correct, Java is no longer installed by default on OS X. I want to ship my app and not force users to download Java before they can use the app.

How can I ship a copy of the java executable along with the runtime (rt.jar). Of course I can copy rt.jar in the app bundle of course but what about the java binary? Can I just copy this as well?

edwardmp
  • 6,339
  • 5
  • 50
  • 77

3 Answers3

1

I think in your case, the best option would be to include the Java Installer Kernel (small install that downloads and installs the latest version of Java, if necessary).

The main problem with bundling the binaries per-se in your app is basically, security. Vulnerabilities are discovered routinely in the JRE and patched. If you bundle an specific version and a vulnerability is discovered after your release, you will be basically weakening the security of the machines where your application is installed. As you obviously don't want to do that, it is better to try to include logic to detect if a compatible version is present, or otherwise properly install the right version. Many installer packages include options like this: For example, OpenOffice/LibreOffice are native apps but they require Java to be present, and they use a similar installation method as the one described above.

  • By the way, you could add some simple logic to obtain the latest version number for Java (http://java.com/en/download/installed8.jsp), and then download/install that version. – Milton Hernandez Jul 17 '16 at 17:37
  • 1
    Also, if money is no object, you could make your Java App into a JRE-less executable using this: https://www.excelsiorjet.com . – Milton Hernandez Jul 17 '16 at 17:41
1

Each self-contained application package includes the following items:

Application code, packaged into a set of JAR files, plus any other application resources (data files, native libraries)

Copy of the JRE, to be used by this application only

Native launcher for the application, multiple launchers for a single package are supported

Metadata, such as icons

Multiple package formats are possible. Built-in support is provided for several types of packages. You can also assemble your own packages by post-processing a self-contained application packaged as a folder, for example if you want to distribute your application as a ZIP file.

--

Self-contained application packages have the following drawbacks:

"Download and run" user experience

Unlike web deployment, the user experience is not about "launch the application from the web." It is more one of "download, install, and run" process, in which the user might need to go through additional steps to get the application launched. For example, the user might have to accept a browser or operating system security dialog, or find and launch the application installer from the download folder.

Larger download size

In general, the size of self-contained application packages is larger than the size of a standalone application, because a private copy of the JRE is included.

Package per target platform

Self-contained application packages are platform-specific and can only be produced for the same system on which you build. To deliver self-contained application packages on Windows, Linux, and OS X, you must build your project on all three platforms.

Application updates are the responsibility of developer

Web-deployed Java applications automatically download application updates from the web as soon as they are available. The Java Autoupdate mechanism takes care of updating the JRE to the latest secure version several times every year. Self-contained applications do not have built-in support for automatic updates.

0

You can ship a JRE with your app (see licensing). To give the user a copy of JRE, put one in and let them install it themselves or make a application bundle.

user383
  • 139
  • 5
  • Thanks for the response. Note that the main app is an Objective-c app, it just runs a java command at some point. Application bundles are pure Java apps, so this isn't what I can use for this. So probably copy 'rt.jar' and the Java binary (e.g. /usr/bin/java). Can I just copy the binary and will it work on all OSX versions? – edwardmp Jun 25 '16 at 09:07