Most certainly, export JAVA_HOME=/usr/bin/java
is the culprit. This env var should point to the JDK or JRE installation directory. Googling shows that the best option for MacOS X seems to be export JAVA_HOME=/Library/Java/Home
.
http://stackoverflow.com/questions/10873437/unable-to-locate-an-executable-at-usr-bin-java-bin-java-1