#!/bin/sh -p
#
# @(#)java_wrapper    99/03/09
#
# IBM Linux version
#
unset ENV

PRG=`type -path $0` >/dev/null 2>&1
progname=${0##*/}  
suffix=$(expr "$progname" : '.*\(_.$\)')
JAVAHOME=${PRG%/*}/..

# Resolve symlinks. See 4152645.
while [ -L "$PRG" ]; do
    ls=`/bin/ls -ld "$PRG"`
    link=`/usr/bin/expr "$ls" : '.*-> \(.*\)$'`
    if /usr/bin/expr "$link" : '/' > /dev/null; then
        PRG="$link"
    else
        PRG=${PRG%/*}/$link
    fi
    PRG=`type -path $PRG` >/dev/null 2>&1
    JAVAHOME=${PRG%/*}/..
    progname=`basename $PRG`
done

# export JAVAHOME for GetPropertiesMD()
JAVAHOME=`""cd $JAVAHOME; pwd`
export JAVAHOME

JREHOME=$JAVAHOME/jre

# Where is the JRE in relation to the executable?
unset jre
if [ -f "${JREHOME}/bin/libjava${suffix}.so" ]; then
    jre="${JREHOME}"
fi
if [ -f "${JAVAHOME}/bin/libjava${suffix}.so" ]; then
    jre="${JAVAHOME}"
fi
if [ "x${jre}" = "x" ]; then
    echo "Error: can't find libjava${suffix}.so"
    exit 1
fi

export LD_LIBRARY_PATH=$jre/bin:$jre/bin/classic:$LD_LIBRARY_PATH

# Ensure that RedHat 7.1 does not use floating stacks		ibm@29353
# Note that this does *not* mean we use a 2.2 kernel!
export LD_ASSUME_KERNEL=2.2.5 

prog="$JAVAHOME/bin/exe/${progname}"

# Run.
if [ -x "$prog" ]
then
    exec $DEBUG_PROG "$prog" "$@"
else
    echo >&2 "$progname was not found in $JAVAHOME/bin/exe"
    exit 1
fi
