#!/bin/sh

cd /usr/local/aejava/lib

#
# Make sure the needed environment variables are set.
#
if [ "$AEJHOME" = "" ]
then
   echo ""
   echo "** AEJHOME must be defined"
   exit 1
elif [ "$JAVA_HOME" = "" ]
then
   echo ""
   echo "** JAVA_HOME must be defined"
   exit 1
fi

#
# Determine platform.
#
PLATFORM=`uname -a | cut -f1 -d" "`; export PLATFORM

#
# process (optional) command-line arguments
# which are assumed to be options for the java executable
#
InitialMemory="-Xms24m"
MaximumMemory="-Xmx256m"
Options=""

for arg in $*
do
   case $arg in
      -Xms*)
         InitialMemory="$arg" ;;
      -Xmx*)
         MaximumMemory="$arg" ;;
      *)
         Options="$Options $arg"
   esac
done
Options="$Options $InitialMemory $MaximumMemory"

if [ "$PLATFORM" = "SunOS" ]
then
   #
   # Check LANG variable - Help would not come up from ArcExplorer if LANG="C"
   # This happens on Solaris and HP platforms only 
   #
   if [ "$LANG" = "C" ]
   then
      export LANG="en_US"
   fi
elif [ "$PLATFORM" = "AIX" ]
then
   Options="-Djava.compiler=NONE $Options"
elif [ "$PLATFORM" = "HP-UX" ]
then
   #
   # Check LANG variable - Help would not come up from ArcExplorer if LANG="C"
   # This happens on Solaris and HP platforms only
   #
   if [ "$LANG" = "C" ]
   then
      export LANG="en_US.iso88591"
   fi
fi

#
# Set the LD_LIBRARY_PATH variable for Solaris and Linux to include AEJHOME/lib
# so that the JAI libraries are in the path.
#
if [ "$PLATFORM" = "SunOS" -o "$PLATFORM" = "Linux" ]
then
   if [ -z $LD_LIBRARY_PATH ]
   then
      LDPATH=$AEJHOME/lib
   else
      LDPATH=$AEJHOME/lib:$LD_LIBRARY_PATH
   fi
   export LD_LIBRARY_PATH=$LDPATH
fi

#
# run ArcExplorer - Select the appropriate method to run ArcExplorer 
# 

#
# Use the next two lines if you have NOT copied the Viewer JAR file
# to the JRE/lib directory.  Comment them if you did, and uncomment
# the line in the following section.
#
JARHOME=$AEJHOME/lib
$JAVA_HOME/bin/java $Options -cp $JARHOME/jaxp.jar:$JARHOME/parser.jar:$JARHOME/arcims_aej.jar:$JARHOME/arcims_resaej.jar:$JARHOME/esri_mo10.jar:$JARHOME/esri_mo10res.jar:$JARHOME/jsde83_sdk.jar:$JARHOME/jsde83_sdkres.jar:$JARHOME/jai_codec.jar:$JARHOME/jai_core.jar:$JARHOME/mlibwrapper_jai.jar:$JARHOME/jcert.jar:$JARHOME/jnet.jar:$JARHOME/jsse.jar:$JARHOME/ogcClient0213.jar:$JARHOME/crimson.jar:$JARHOME/esri_xmlkit.jar:$JARHOME/jaxp.jar:$JARHOME/xalan.jar com.esri.ae.AE

#
# Uncomment the next line if you have copied the Viewer JAR files
# to the JRE/lib directory.  Comment the 2 lines above this.
#
# $JAVA_HOME/bin/java $Options com.esri.ae.AE
