On Mac OS X, there is a very specific, managed directory structure for the various Java versions that are installed. The general directory is "/System/Library/Frameworks/JavaVM.framework/". For those of us new to Mac OS X, the sub-directories under there look a little foreign.
To run WLS, you need to set JAVA_HOME to the appropriate directory before you can start a domain. Hardcoding the directory into either .bashrc or the startWebLogic.sh scripts does the trick.
But today I stumbled on another little utility that can be used to dynamically determine the current JAVA_HOME, as set in the user preferences:
NAME java_home - return a value for $JAVA_HOME SYNOPSIS /usr/libexec/java_home [options] DESCRIPTION The java_home command returns a path suitable for setting the JAVA_HOME environment variable. It determines this path from the user's preferred Java in the Java Preferences application. Additional constraints may be provided to filter the list of JVMs available. By default, if no constrants match the available list of JVMs, the default order is used. The path is printed to standard output.
Thus setting JAVA_HOME dynamically in scripts, shell profiles can be done simply like this: