imagej / imagej-launcher

The ImageJ native launcher
https://imagej.net/learn/launcher
BSD 2-Clause "Simplified" License
21 stars 23 forks source link

Support bundled Java 8 on OSX #36

Closed hinerm closed 8 years ago

hinerm commented 8 years ago

Mac-specific Java detection now supports a bundled Java (in ImageJ.app/java).

Updates the dylib detection to properly match Java 8 binaries.

Closes #35

hinerm commented 8 years ago

Pending verification by @ctrueden

ctrueden commented 8 years ago

So, after much debugging and testing... this branch also fixes the problem (on my system) where Java 7 was being chosen over Java 8.

The reason Java 7 was chosen is because the jdk1.7.0_80.jdk folder has the newest timestamp:

$ ls -lt /Library/Java/JavaVirtualMachines
total 0
drwxr-xr-x  3 root  wheel  102 Nov 11 09:28 jdk1.7.0_80.jdk/
drwxr-xr-x  3 root  wheel  102 Oct 29 15:23 jdk1.8.0_66.jdk/
drwxr-xr-x  3 root  wheel  102 Jul 14 16:52 1.6.0.jdk/
drwxr-xr-x  3 root  wheel  102 Jun  8  2015 jdk1.8.0_45.jdk/
drwxr-xr-x  3 root  wheel  102 Jul 29  2014 jdk1.8.0_11.jdk/
drwxr-xr-x  3 root  wheel  102 Mar 31  2014 jdk1.8.0.jdk/
drwxr-xr-x  3 root  wheel  102 Nov 13  2013 jdk1.7.0_45.jdk/
drwxr-xr-x  3 root  wheel  102 Oct 10  2013 1.6.0_65-b14-462.jdk/
drwxr-xr-x  3 root  wheel  102 May 20  2013 1.6.0_45-b06-451.jdk/
drwxr-xr-x  3 root  wheel  102 May 20  2013 jdk1.7.0_21.jdk/

I guess that will not be the case for most people's systems. But nonetheless: is timestamp really a reliable way to go about detecting the best Java to use? Personally I think asking /usr/libexec/java_home for the user's preferred JVM is a more robust way to go, and will do what people expect in more cases. So I went ahead and added that feature (after several refactoring commits which facilitate it) as f324748a36cf4026c7a233246c21cc440854e5f5.

And now I merge, since I think this work is a big step forward!

Actually, my favorite thing about this branch is the beefing up of all the debug statements, so you can really tell what the launcher is "thinking" when it comes to Java detection on OS X systems. Very helpful. Just be sure to launch with DEBUG=1 .../ImageJ-macosx instead of .../ImageJ-macosx --debug, since the latter does not turn on debug mode early enough to be useful.

ctrueden commented 8 years ago

Also worth noting that as part of this branch, Mark fixed the detection of libjvm.dylib in many cases, including /Library/Internet Plug-Ins/JavaAppletPlugin.plugin (i.e.: the JRE installed from java.com). This also may fix the problems with Dock drag-and-drop on some people's systems. fingers crossed