Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Mac OS X determine that an application needs Java?

Tags:

java

macos

I am responsible for a Java application which is deployed on multiple platforms including OS X. With recent versions of the application we distribute two separate bundles for OS X - one which uses the JavaApplicationStub provided by Apple, and another one which includes a bundled JDK 7 and uses a launcher produced in-house (a modification of Oracle's JavaAppLauncher).

The issue is, with the latter bundle, Mac OS X still insists on you having Java 6 installed if you try to run the application. Specifically the message says:

"To open (application), you need a Java SE 6 runtime. Would you like to install one now?"

If you don't install Java SE 6, you are unable to run the application, despite the fact that JDK 7 is bundled (and, if you do install Java 6, it nevertheless runs with the bundled Java 7).

What I'm struggling to figure out is how OS X decides that the application requires Java? I've tried renaming the 'Java' dictionary in the Info.plist file, and renaming the Java subfolder within the Resources folder, without success. Does anyone have any ideas? Surely it's possible to have an application with a bundled JDK run without requiring a system JDK to be installed?

like image 964
davmac Avatar asked May 16 '13 15:05

davmac


People also ask

Does MacOS need Java?

Java is not required and is not preinstalled in OS X.

How do I know if I have Java on my Mac?

Type terminal in the search bar and open it by clicking on the icon in the search results. 3. Once in the command line, run the command: java -version . The output should display the Java version installed on your MacOS.


1 Answers

I've found the answer (with help from Mike Swingler on the [email protected] mailing list).

The presence of the 'Java' dictionary in the Info.plist file is what triggers the dialog, however, changing the name of the dictionary after trying to start the app isn't good enough. The system somehow caches the requirement for Java and so simply issues the dialog again. To avoid this it was necessary to download a fresh copy of the application and make the change before trying to run it for the first time (I'm told since that renaming the app would suffice, even renaming it and then again back to the original name).

Fortunately, this means that all we have to do is change the name of the 'Java' dictionary, and alter our customised launcher so that it uses the new dictionary name.

like image 134
davmac Avatar answered Oct 05 '22 12:10

davmac