Skip to content

Instantly share code, notes, and snippets.

@vshank77
Created June 8, 2011 17:48
Show Gist options
  • Select an option

  • Save vshank77/1014916 to your computer and use it in GitHub Desktop.

Select an option

Save vshank77/1014916 to your computer and use it in GitHub Desktop.
set java shell
#!/bin/sh
if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then
if $darwin; then
if [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" ]; then
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home"
fi
else
JAVA_PATH=`which java 2>/dev/null`
if [ "x$JAVA_PATH" != "x" ]; then
JAVA_PATH=`dirname $JAVA_PATH 2>/dev/null`
JRE_HOME=`dirname $JAVA_PATH 2>/dev/null`
fi
if [ "x$JRE_HOME" = "x" ]; then
if [ -x /usr/bin/java ]; then
JRE_HOME=/usr
fi
fi
fi
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
fi
fi
if [ -z "$JRE_HOME" ]; then
JRE_HOME="$JAVA_HOME"
fi
if [ -z "$BASEDIR" ]; then
echo "The BASEDIR environment variable is not defined"
echo "This environment variable is needed to run this program"
exit 1
fi
if [ ! -x "$BASEDIR"/bin/setjava.sh ]; then
if $os400; then
eval
else
echo "The BASEDIR environment variable is not defined correctly"
echo "This environment variable is needed to run this program"
exit 1
fi
fi
# Set standard commands for invoking Java.
_RUNJAVA="$JRE_HOME"/bin/java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment