Ubiquity Unifi cannot locate Java Home

After installing ubiquity unifi, you may face error saying that the UniFi fail to start because it fail to locate java home; the solution is simple which just required to edit the JAVA_HOME on the init script :

$ vim /etc/init.d/unifi

Find the JAVA_HOME=/usr/lib/jvm//usr/lib/jvm/java-7-openjdk-amd64 and add your instance architecture type after that string. For example :

JAVA 8 : JAVA_HOME=/usr/lib/jvm/java-8-oracle
JAVA 7 : JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

Don’t change anything else and don’t forget to save after that. Finally restart the UniFi,

$ sudo service unifi restart