For version 5.10.24 of Unifi Controller software on Ubuntu 18.04 LTS with Java jdk 8u211 Unifi was unable to locate java home.
My solution was to edit /etc/init.d/unifi. In the function set_java_home() change the entire contents to:
JAVA_HOME=type -p java|xargs readlink -f|xargs dirname|xargs dirname
This is based on a discussion at https://community.ubnt.com/t5/UniFi-Wireless/Java-Home-Directory-Fail-Issue-on-Ubuntu-RESOLVED/td-p/474037.
This, strangely, was not an issue on a separate install. The difference seems to be IBM Java vs OpenJDK. Only the IBM Java system had the issue.