$cd native; ./configure --with-apr=`apr-1-config --prefix` checking build system type... x86_64-apple-darwin10.8.0 checking host system type... x86_64-apple-darwin10.8.0 checking target system type... x86_64-apple-darwin10.8.0 checking for a BSD-compatible install... /usr/bin/install -c checking for working mkdir -p... yes Tomcat Native Version: 1.1.22 checking for chosen layout... tcnative checking for APR... yes setting CC to "gcc" setting CPP to "gcc -E" checking for a BSD-compatible install... /usr/bin/install -c configure: error: can't locate a valid JDK location checking for JDK location (please wait)... checking Try to guess JDK location...
Strange, why can't it locate a JDK? Looks like the code that failed is in native/build/tcnative.m4: if test -z "${JAVA_HOME}" ; then # Oh well, nobody set neither JAVA_HOME nor JAVA_HOME, have to guess # The following code is based on the code submitted by Henner Zeller # for ${srcdir}/src/scripts/package/rpm/ApacheJServ.spec # Two variables will be set as a result: # # JAVA_HOME # JAVA_PLATFORM AC_MSG_CHECKING([Try to guess JDK location]) for JAVA_PREFIX in /usr/local /usr/local/lib /usr /usr/lib /opt /usr/java /System/Library/Frameworks/JavaVM.framework/Versions/ ; do for JAVA_PLATFORM in 6 5 4 3 2 ; do for subversion in .9 .8 .7 .6 .5 .4 .3 .2 .1 .0 "" ; do for VARIANT in IBMJava2- java java- jdk jdk- ""; do GUESS="${JAVA_PREFIX}/${VARIANT}1.${JAVA_PLATFORM}${subversion}" dnl AC_MSG_CHECKING([${GUESS}]) if test -d "${GUESS}/bin" & test -d "${GUESS}/include" ; then JAVA_HOME="${GUESS}" AC_MSG_RESULT([${GUESS}]) break fi if test -d "${GUESS}/Commands" & test -d "${GUESS}/Headers" ; then JAVA_HOME="${GUESS}" AC_MSG_RESULT([${GUESS}]) break fi done if test -n "${JAVA_HOME}" ; then break; fi done if test -n "${JAVA_HOME}" ; then break; fi done if test -n "${JAVA_HOME}" ; then break; fi done if test ! -n "${JAVA_HOME}" ; then AC_MSG_ERROR(can't locate a valid JDK location) fi fi The loop in that code which is trying a bunch of guesses will eventually get to the following combination of values: JAVA_PREFIX = /System/Library/Frameworks/JavaVM.framework/Versions/ JAVA_PLATFORM = 6 subversion = .0 VARIANT = "" Line 127 constructs a guess: GUESS="${JAVA_PREFIX}/${VARIANT}1.${JAVA_PLATFORM}${subversion}" For the above combination, that guess will be: /System/Library/Frameworks/JavaVM.framework/Versions//1.6.0 On my machine running OS X 10.6.8 (Snow Leopard), here's what that path resolves to: $ ls -l /System/Library/Frameworks/JavaVM.framework/Versions//1.6.0 lrwxr-xr-x 1 root wheel 10 Nov 21 08:42 /System/Library/Frameworks/JavaVM.framework/Versions//1.6.0 -> CurrentJDK Following the symlink: $ ls -l /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK lrwxr-xr-x 1 root wheel 59 Nov 21 08:42 /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents Following the second symlink: $ ls -l /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents total 0 drwxr-xr-x 12 root wheel 408 Nov 21 08:43 Classes drwxr-xr-x 41 root wheel 1394 Nov 21 08:43 Commands drwxr-xr-x 7 root wheel 238 Nov 21 08:43 Home -rw-r--r-- 1 root wheel 1963 Nov 1 12:05 Info.plist drwxr-xr-x 50 root wheel 1700 Nov 21 08:43 Libraries drwxr-xr-x 3 root wheel 102 Nov 21 08:43 MacOS drwxr-xr-x 21 root wheel 714 Nov 21 08:43 Resources -rw-r--r-- 1 root wheel 454 Nov 1 12:08 version.plist So there is a directory here with some useful JDK-type things in it. The Home subdirectory here does look like something that would be universally recognized as a JAVA_HOME: $ ls -l /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/ total 16 drwxr-xr-x 41 root wheel 1394 Nov 21 08:43 bin lrwxr-xr-x 1 root wheel 3 Nov 21 08:42 bundle -> ../ lrwxr-xr-x 1 root wheel 51 Nov 21 08:42 include -> /System/Library/Frameworks/JavaVM.framework/Headers drwxr-xr-x 42 root wheel 1428 Nov 21 08:43 lib drwxr-xr-x 41 root wheel 1394 Nov 1 12:03 man $ ls -l /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/ | grep java -rwxr-xr-x 1 root wheel 100560 Nov 1 12:03 java -rwxr-xr-x 1 root wheel 100560 Nov 1 12:03 javac -rwxr-xr-x 1 root wheel 100560 Nov 1 12:03 javadoc -rwxr-xr-x 1 root wheel 100560 Nov 1 12:03 javah -rwxr-xr-x 1 root wheel 100560 Nov 1 12:03 javap lrwxr-xr-x 1 root wheel 67 Nov 21 08:42 javaws -> /System/Library/Java/Support/Deploy.bundle/Contents/Home/bin/javaws At the point it isn't clear to me which directory we actually want. This script checks for some directories that look like they're apple-named: if test -d "${GUESS}/Commands" & test -d "${GUESS}/Headers" ; then JAVA_HOME="${GUESS}" AC_MSG_RESULT([${GUESS}]) break fi However, as the above listing shows, in /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents we have a “Commands” subdirectory but no “Headers” subdirectory. I think that's the reason it's coming up empty here. There is another location on OS X that does have both a “Commands” subdirectory and a “Headers” subdirectory: $ ls -l /System/Library/Frameworks/JavaVM.framework total 72 lrwxr-xr-x 1 root wheel 27 Nov 21 08:42 Classes -> Versions/CurrentJDK/Classes lrwxr-xr-x 1 root wheel 24 Nov 21 08:42 CodeResources -> Versions/A/CodeResources lrwxr-xr-x 1 root wheel 28 Nov 21 08:42 Commands -> Versions/CurrentJDK/Commands lrwxr-xr-x 1 root wheel 27 Nov 21 08:42 Frameworks -> Versions/Current/Frameworks lrwxr-xr-x 1 root wheel 24 Nov 21 08:42 Headers -> Versions/Current/Headers lrwxr-xr-x 1 root wheel 24 Nov 21 08:42 Home -> Versions/CurrentJDK/Home lrwxr-xr-x 1 root wheel 23 Nov 21 08:42 JavaVM -> Versions/Current/JavaVM lrwxr-xr-x 1 root wheel 29 Nov 21 08:42 Libraries -> Versions/CurrentJDK/Libraries lrwxr-xr-x 1 root wheel 26 Nov 21 08:42 Resources -> Versions/Current/Resources drwxr-xr-x 13 root wheel 442 Nov 21 08:45 Versions However, this code as written will not check that location. There seem to be a few ways this could be patched to find a valid JDK location. May main question is, which is most preferable? My guess is that if JAVA_HOME has not been set, in this particular situation we probably want it to land on /System/Library/Frameworks/JavaVM.framework