#!/bin/sh


if [ ! -r ${NGC_HOME}/nextgen2.jar ]; then
  echo '${NGC_HOME} does not point to a working NGC distribution';
  exit 1
fi

CLASSPATH=${CLASSPATH}:${NGC_HOME}/nextgen2.jar

set -- $(getopt "" -- "$@")
for i
do
  case "$1" in 
      -client) MODE_FLAGS=" -client ";;
      -server) MODE_FLAGS=" -server ";;
      -[a-z]*) ;;
      --[a-z]*) ;;
      --) ;;
      *) break;;
  esac
  shift
done

# echo "flags : $MODE_FLAGS";
# echo "rest  : $*"

# no jar support right now
#   or  java [-options] -jar jarfile [args...]
#           (to execute a jar file)

if [ ! "$*" ]; then
   echo "Usage: java [-options] class [args...]
           (to execute a class)

where options include: 
    -client       to select the \"client\" VM
    -server       to select the \"server\" VM
"
   exit 0
fi

#FLAGS="-Xms64m -Xmx64m"
FLAGS="-Xms128m -Xmx128m"
export CLASSPATH

java ${MODE_FLAGS} ${FLAGS} edu.rice.cs.nextgen2.classloader.Runner $*
