#!/bin/sh

#
# Check for properties file
#
if [ ! -r "$JAVA_HOME/lib/appletviewer.properties" ] ; then
    echo "Could not read properties file: $JAVA_HOME/lib/appletviewer.properties" 1>&2 
    exit 1
fi

#
# Create .hotjava directory
#
if [ ! -d "$HOME/.hotjava" ] ; then
    echo "Creating $HOME/.hotjava directory"
    /bin/mkdir -p $HOME/.hotjava
fi

#
# source a script that extracts RUNTIME_ARGS and APP_ARGS
#
. `dirname $0`/.extract_args

#
# Strip -debug from APP_ARGS
#
debugging=false
for a in $APP_ARGS; do
   case "$a" in 
    -debug) debugging=true  ;;
    *)      args="$args $a" ;;
   esac
done


#
# Run the applet viewer. We hardwire the debugger's class -- oh, well.
#
curdir=`dirname $0`
if test "$debugging" = "true"
then
    if [ -x $curdir/java_g_X ]; then
       prog=java_g_X
    else
       prog=java_g
    fi
    $curdir/$prog $RUNTIME_ARGS sun.tools.ttydebug.TTY \
                                          sun.applet.AppletViewer ${args}
else
    if [ -x $curdir/java_X ]; then
       prog=java_X
    else
       prog=java
    fi
    $curdir/$prog $RUNTIME_ARGS sun.applet.AppletViewer ${args}
fi
