Comment 3 for bug 1556997

Revision history for this message
Éric Piel (Delmic) (piel) wrote : Re: JAVA_HOME auto-detection fails due to whitespace in update-java-alternatives output

This bug has been reported also in debian, as bug #820097. (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=820097)...
and fixed. The fixed version is already available for the next Ubuntu (Yakkety), in version 1.50i+dfsg-1. So maybe importing that newer version in Xenial would be fine.

Alternatively, the fix is a one line patch:
--- imagej-1.50d+dfsg/debian/imagej.sh 2014-03-12 12:58:36.000000000 +0000
+++ imagej-1.50i+dfsg/debian/imagej.sh 2016-04-07 12:57:41.000000000 +0000
@@ -29,7 +29,7 @@

 if [ -z "$JAVA_HOME" ] ; then
     # This does not work see #505315
- JAVA_HOME=$(/usr/sbin/update-java-alternatives -l | grep openjdk | sort | tail -1 | cut -d' ' -f 3)
+ JAVA_HOME=$(/usr/sbin/update-java-alternatives -l | grep openjdk | sort | tail -1 | tr -s ' ' | cut -d' ' -f 3)
     # Reverted to old version - see #558222 (Andreas Tille)
     # JAVA_HOME=$(dirname $(dirname $(dirname $(readlink /etc/alternatives/java))))
     # Also suggested by From: JR Coding <email address hidden>; To: <email address hidden>