hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1135333 - in /hadoop/common/trunk/common: CHANGES.txt bin/hadoop-config.sh
Date Mon, 13 Jun 2011 22:45:34 GMT
Author: eli
Date: Mon Jun 13 22:45:34 2011
New Revision: 1135333

URL: http://svn.apache.org/viewvc?rev=1135333&view=rev
Log:
HADOOP-6605. Add JAVA_HOME detection to hadoop-config. Contributed by Eli Collins

Modified:
    hadoop/common/trunk/common/CHANGES.txt
    hadoop/common/trunk/common/bin/hadoop-config.sh

Modified: hadoop/common/trunk/common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/common/CHANGES.txt?rev=1135333&r1=1135332&r2=1135333&view=diff
==============================================================================
--- hadoop/common/trunk/common/CHANGES.txt (original)
+++ hadoop/common/trunk/common/CHANGES.txt Mon Jun 13 22:45:34 2011
@@ -215,6 +215,8 @@ Trunk (unreleased changes)
     HADOOP-7106. Reorganize project SVN layout to "unsplit" the projects.
     (todd, nigel)
 
+    HADOOP-6605. Add JAVA_HOME detection to hadoop-config. (eli)
+
   OPTIMIZATIONS
   
     HADOOP-7333. Performance improvement in PureJavaCrc32. (Eric Caspole

Modified: hadoop/common/trunk/common/bin/hadoop-config.sh
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/common/bin/hadoop-config.sh?rev=1135333&r1=1135332&r2=1135333&view=diff
==============================================================================
--- hadoop/common/trunk/common/bin/hadoop-config.sh (original)
+++ hadoop/common/trunk/common/bin/hadoop-config.sh Mon Jun 13 22:45:34 2011
@@ -107,18 +107,26 @@ fi
 # we use in Hadoop. Tune the variable down to prevent vmem explosion.
 export MALLOC_ARENA_MAX=${MALLOC_ARENA_MAX:-4}
 
-# some Java parameters
-if [ "$JAVA_HOME" != "" ]; then
-  #echo "run java in $JAVA_HOME"
-  JAVA_HOME=$JAVA_HOME
-fi
-  
-if [ "$JAVA_HOME" = "" ]; then
-  echo "Error: JAVA_HOME is not set."
-  exit 1
+# Attempt to set JAVA_HOME if it is not set
+if [[ -z $JAVA_HOME ]]; then
+  # On OSX use java_home (or /Library for older versions)
+  if [ "Darwin" == "$(uname -s)" ]; then
+    if [ -x /usr/libexec/java_home ]; then
+      export JAVA_HOME=($(/usr/libexec/java_home))
+    else
+      export JAVA_HOME=(/Library/Java/Home)
+    fi
+  fi
+
+  # Bail if we did not detect it
+  if [[ -z $JAVA_HOME ]]; then
+    echo "Error: JAVA_HOME is not set and could not be found." 1>&2
+    exit 1
+  fi
 fi
 
 JAVA=$JAVA_HOME/bin/java
+# some Java parameters
 JAVA_HEAP_MAX=-Xmx1000m 
 
 # check envvars which might override default args



Mime
View raw message