Skip to content

Commit

Permalink
Support JDK 1.7+ on OS X
Browse files Browse the repository at this point in the history
Since 1.7 installation directory of the JDK has changed and is now
installed under

/Library/Java/JavaVirtualMachines/${JAVA_VERSION}/Contents/Home

and tools.jar is in ${JAVA_HOME}/lib/tools.jar
  • Loading branch information
oschrenk authored and jbachorik committed Jun 24, 2015
1 parent 0dd2bbd commit 404d3ea
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions bin/btrace
Expand Up @@ -10,32 +10,32 @@ fi

if [ -f "${BTRACE_HOME}/build/btrace-client.jar" ] ; then
if [ "${JAVA_HOME}" != "" ]; then
case "`uname`" in
Darwin*)
# In Mac OS X, tools.jar is classes.jar and is kept in a
# different location. Check if we can locate classes.jar
# based on ${JAVA_VERSION}
TOOLS_JAR="/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Classes/classes.jar"
TOOLS_JAR="${JAVA_HOME}/lib/tools.jar"
if [ ! -f ${TOOLS_JAR} ] ; then
case "`uname`" in
Darwin*)
# In older JDK versions for Mac OS X, tools.jar is classes.jar
# and is kept in a different location. Check if we can locate
# classes.jar based on ${JAVA_VERSION}
TOOLS_JAR="/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Classes/classes.jar"

# if we can't find, try relative path from ${JAVA_HOME}. Usually,
# /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
# is JAVA_HOME. (or whatever version beyond 1.6.0!)
if [ ! -f ${TOOLS_JAR} ] ; then
TOOLS_JAR="${JAVA_HOME}/../Classes/classes.jar"
fi
# if we can't find, try relative path from ${JAVA_HOME}. Usually,
# /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
# is JAVA_HOME. (or whatever version beyond 1.6.0!)
if [ ! -f ${TOOLS_JAR} ] ; then
TOOLS_JAR="${JAVA_HOME}/../Classes/classes.jar"
fi

# If we still can't find, tell the user to set JAVA_VERSION.
# This way, we can avoid zip file errors from the agent side
# and "connection refused" message from client.
if [ ! -f ${TOOLS_JAR} ] ; then
echo "Please set JAVA_VERSION to the target java version"
exit 1
fi
;;
*)
TOOLS_JAR="${JAVA_HOME}/lib/tools.jar"
;;
esac
# If we still can't find, tell the user to set JAVA_VERSION.
# This way, we can avoid zip file errors from the agent side
# and "connection refused" message from client.
if [ ! -f ${TOOLS_JAR} ] ; then
echo "Please set JAVA_VERSION to the target java version"
exit 1
fi
;;
esac
fi
${JAVA_HOME}/bin/java -cp ${BTRACE_HOME}/build/btrace-client.jar:${TOOLS_JAR}:/usr/share/lib/java/dtrace.jar com.sun.btrace.client.Main $*
else
echo "Please set JAVA_HOME before running this script"
Expand Down

0 comments on commit 404d3ea

Please sign in to comment.