Bug 37284 - guess JDK location on Mac OS X
guess JDK location on Mac OS X
Status: RESOLVED FIXED
Product: Tomcat 5
Classification: Unclassified
Component: Native:Packaging
Unknown
Macintosh Mac OS X 10.4
: P2 trivial (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2005-10-27 23:30 UTC by Stepan Koltsov
Modified: 2005-11-18 07:55 UTC (History)
0 users



Attachments
The patch (same as in report text) (1.60 KB, patch)
2005-10-27 23:33 UTC, Stepan Koltsov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stepan Koltsov 2005-10-27 23:30:08 UTC
Under Mac OS X there is defined standard JDK location. JDK 1.5 shipped by Apple is always installed to 
/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home.

Simple patch checks whether this JDK exists if JAVA_HOME and JRE_HOME are unset.

===
--- ./catalina.sh.orig  2005-10-28 01:12:12.000000000 +0400
+++ ./catalina.sh       2005-10-28 01:11:38.000000000 +0400
@@ -45,9 +45,11 @@
 # OS specific support.  $var _must_ be set to either true or false.
 cygwin=false
 os400=false
+darwin=false
 case "`uname`" in
 CYGWIN*) cygwin=true;;
 OS400*) os400=true;;
+Darwin*) darwin=true;;
 esac
 
 # resolve links - $0 may be a softlink
--- ./setclasspath.sh.orig      2005-10-28 01:10:05.000000000 +0400
+++ ./setclasspath.sh   2005-10-28 01:19:52.000000000 +0400
@@ -10,9 +10,13 @@
 
 # Make sure prerequisite environment variables are set
 if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then
-  echo "Neither the JAVA_HOME nor the JRE_HOME environment variable is defined"
-  echo "At least one of these environment variable is needed to run this program"
-  exit 1
+  if $darwin && [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home" ]; then
+    export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home"
+  else
+    echo "Neither the JAVA_HOME nor the JRE_HOME environment variable is defined"
+    echo "At least one of these environment variable is needed to run this program"
+    exit 1
+  fi
 fi
 if [ -z "$JAVA_HOME" -a "$1" = "debug" ]; then
   echo "JAVA_HOME should point to a JDK in order to run in debug mode."
--- ./startup.sh.orig   2005-10-28 01:10:30.000000000 +0400
+++ ./startup.sh        2005-10-28 01:11:01.000000000 +0400
@@ -7,9 +7,11 @@
 
 # Better OS/400 detection: see Bugzilla 31132
 os400=false
+darwin=false
 case "`uname`" in
 CYGWIN*) cygwin=true;;
 OS400*) os400=true;;
+Darwin*) darwin=true;;
 esac
 
 # resolve links - $0 may be a softlink
===
Comment 1 Stepan Koltsov 2005-10-27 23:33:40 UTC
Created attachment 16824 [details]
The patch (same as in report text)
Comment 2 Yoav Shapira 2005-11-18 16:55:06 UTC
Thanks for submitting this enhancement.  I've applied it for 5.5.13.