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 <jr.cod...@googlemail.com>; To: 740...@bugs.debian.org ** Bug watch added: Debian Bug tracker #820097 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=820097 -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1556997 Title: JAVA_HOME auto-detection fails due to whitespace in update-java- alternatives output To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/imagej/+bug/1556997/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs