2

In short: On a mac with a clean installation of Yosemite, doubleclicking a compiled Java mac-style .app application bundle fails to launch the app, unless Apple's Java 6 is installed, even if the current version of Java for the Mac from Oracle is installed.

At length: When Apple developed the Java SDK for macosx, you could open a .app mac-style application bundle written in Java by doubleclicking its icon in Finder, its app icon will show up in your dock while it was running, and its menu items would live in the Mac OS menu bar. Java apps behaved almost like native Mac apps.

On the other hand, if you install the current Java SDK from Oracle, you can execute your Java application with java -jar YourApp.app/Contents/Resources/Java/yourapp.jar, but you get a generic dock icon, your menu items live on top of the window instead of menu bar.

And if you don't have Java 6 from Apple installed on the machine, which is not included in recent versions of the OS but still available for download from Apple at this location (but it's pretty out of date at this point), then you just get an error message dialogue: "To open YourApp.app you need to install the legacy Java SE 6 runtime." with a link to Apple's outdated implementation, even though you already have Oracle's Java 8 installed already.

On a Mac with Java 8 from Oracle installed, but not Java 6 from Apple, is there a way to open a Java app from finder, or retain these other native platform compatibilities? Is there a way to force a .app bundle to use your preferred Java installation?

I'm basically asking the same question as To open “Eclipse” you need to install the legacy Java SE 6 runtime. Is there a solution to this problem other than installing legacy Java 6?

Also this question may be relevant: Application is using Java 6 from Apple instead of Java 7 from Oracle on Mac OS X?

At the questions Run java bundled in .app from command-line and Why is Java SE 6 Legacy required to open Intellij?, it is suggested that you can force your Java .app bundle to use a newer version of Java if you change the JVMVersion in YourApp.app/Contents/Info.plist, but this did not work for me. Those answers are from Java 1.7 era, maybe it's outdated?

ziggurism
  • 616

1 Answers1

1

From replies to a question I asked on Apple's java-dev list it would appear that on a Mac with Java 8 from Oracle installed, but not Java 6 from Apple, there is no current way to open a Java application bundle that was created using Apple's own old jar bundler technology. I suspect this is because the JavaApplicationStub is written to expect some aspect of Apple's Java not present in Oracle's Java.

From a user's point of view the only thing to do would seem to be to download and install Java 6 from https://support.apple.com/kb/DL1572 while it is still available.

From a developer's point of view the safest bet would be to embed Java within one's application bundle using a tool such as jwrapper (www.jwrapper.com). Alternatively there may be tools for creating a bundle that will run with Oracle's Java 8+.

David
  • 280
  • I'm talking about a .app mac-style application bundle, not a jar-file. I have edited the question to make that clearer. – ziggurism Apr 17 '15 at 19:27
  • I've edited my answer. I don't think your question is the same as needing Java 6 to run Eclipse on Yosemite becaue I don't so I have ignored that (although it may possibly be true for an old version of Eclipse). Anyway I'll have a look at that question separately. – David Apr 17 '15 at 22:47
  • Structure Motivator does not work on my Mac. Like all java apps, it gives me an error message asking for Java 6. Screengrab here: http://imgur.com/T1xrpoX. The jar file inside the .app bundle as well as the Unix jar file both ran fine on my machine via Jar launcher. – ziggurism Apr 17 '15 at 23:14
  • It's a Macbook pro running Yosemite 10.10.3. It has Java JDK 1.8 update 45 installed, but never Java 6 from Apple, which seems to be the only version that allows doubleclicking. I have same problem on other Macs, whether new or upgrades from pre-Yosemite. Are you sure you don't have Apple's Java 6 installed? – ziggurism Apr 17 '15 at 23:15
  • Comment for anyone else: Doubleclicking the jar file will not actually run the Java app via Jar launcher, since it is not signed. you have to right-click and choose "open" from the contextual menu to bypass Gatekeeper. Presumably also applies to the .app bundle, if you have a version of Java that will run it. – ziggurism Apr 17 '15 at 23:23
  • I need to check the Mac running Yosemite which is at work. As is an iMac which was bought and set up in 2014 although this is running Mavericks. I certainly didn't do any special Java 6 on that. Will be Monday before I can check. – David Apr 18 '15 at 06:40
  • Apple's java 6 was shipped with the OS before Yosemite. So older machines upgraded to Yosemite may have it automatically. – ziggurism Apr 18 '15 at 06:50
  • OK. I'm still on a list where people might know about this. Will post on that and get back. – David Apr 18 '15 at 06:56
  • Redrafted my answer completely, so in effect it just says no. Difficult to prove this, but have made a suggestion why. – David Apr 19 '15 at 10:06
  • I'm not to fond of the idea of bundling a JRE with the app (although that is also suggested in the documentation for Oracle's appbundler tool see http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html). It's basically the same reason I don't want to install Apple's Java 6: I don't want to have multiple out of date instances of the Java platform on my machine. If I'm going to go to the trouble of keeping an up-to-date installation of Java on my machine, then I want my Java applications to use it. – ziggurism Apr 24 '15 at 04:08
  • I developed a "desktop" app with NetBeans on my MacBook under High Sierra and using Java 8 and JavaFX 8. I can copy the dist jar file and lib folder to another folder and it runs OK. I cannot start it through the finder either by using "Show" or double clicking. I get a message to look in the Console for error messages - which console? AFAIK I have no console app. – Nate Lockwood May 07 '18 at 19:48
  • @NateLockwood — Actually you have two Console apps. One is Apple's, which you will find in Go>Utiiities. This is a useful tool for developers as you can find various logs and error messages there, although it may take you a while to find where to look. But Java apps have their own console where error messages are written. You need to go into System Preferences > Java and then wait until the Java Control Panel opens. The go to the Advanced tab and under the second item you will find "Java console". It is hiden by default, so click show. It will only appear if an error is written to it. – David May 07 '18 at 20:40
  • @NateLockwood — I can't help you with Netbeans, but if you are using Java 8 the problem described most likely does not apply. Like most people I use Eclipse nowadays, where I always export as a double-clickable jar file. If I want to make it into an Apple app I edit an older bundle I already have. – David May 07 '18 at 20:45
  • @David I found the Apple Console, thanks, but when I select Java in System Preferences I get a pop-up "The Java Control Panel opens in a separate window." But nothing appears. Clicking on "Re-open the Java Control Panel" just gives me the same pop-up. Perhaps Eclipse can import a NetBeans project. – Nate Lockwood May 08 '18 at 23:10