Modified the setting of JAVA_HOME for linux to be more generic.
[controller.git] / opendaylight / distribution / opendaylight / src / main / resources / run.sh
index 58ead435103c24fd27d99f8d8f541b6135611027..e4c20da350b87fac520cab4b9d2dac48881f1810 100755 (executable)
@@ -11,8 +11,14 @@ fi
 if [[ $platform == 'linux' ]]; then
    fullpath=`readlink -f $0`
 
-   [[ -z ${JAVA_HOME} ]] && [[ -x "/usr/lib/jvm/java-1.7.0" ]] && export JAVA_HOME='/usr/lib/jvm/java-1.7.0';
+   if [[ -z ${JAVA_HOME} ]]; then
+      # Find the actual location of the Java launcher:
+      java_launcher=`which java`
+      java_launcher=`readlink -f "${java_launcher}"`
 
+      # Compute the Java home from the location of the Java launcher:
+      export JAVA_HOME="${java_launcher%/bin/java}"
+    fi
 elif [[ $platform == 'osx' ]]; then
    TARGET_FILE=$0
    cd `dirname $TARGET_FILE`