better heuristics to guess correct JAVA_HOME
When JAVA_HOME is not defined,
guess whether we're using OpenJDK or Oracle Java
by using java -version string. ONOS-1159
Change-Id: Ia2994722aec16c1f49cda05c51728854332ea815
diff --git a/ramcloud-build-scripts/build_jni_so.sh b/ramcloud-build-scripts/build_jni_so.sh
index e549e6a..bd4be1e 100755
--- a/ramcloud-build-scripts/build_jni_so.sh
+++ b/ramcloud-build-scripts/build_jni_so.sh
@@ -1,8 +1,22 @@
#!/bin/bash
+if [ -z "${JAVA_HOME}" ]; then
+ echo "JAVA_HOME not set"
+ OPENJDK=`java -version 2>&1 | grep OpenJDK`
+ if [ -z "${OPENJDK}" -a -d "/usr/lib/jvm/java-7-oracle" ]; then
+ JAVA_HOME=/usr/lib/jvm/java-7-oracle
+ else
+ JAVA_HOME=/usr/lib/jvm/default-java
+ fi
+ echo "Assuming JAVA_HOME=${JAVA_HOME}"
+fi
+
# fail on command error
set -e
+# echo back each command
+set -x
+
JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-oracle}
ONOS_HOME=${ONOS_HOME:-~/ONOS}
RAMCLOUD_HOME=${RAMCLOUD_HOME:-~/ramcloud}