#!/bin/bash
# remove double bootclasspath entries:
BOOTCLASSPATH=""
BOOTCLASSPATH=$(find /opt/local/share/java -name "libgcj*.jar" -print | tr "\n" ":"):$(find /opt/local/share/java/ -name "glibj*.jar" -print | tr "\n" ":")
OPTIONS=""
while [ $# -gt 0 ]
do
  if [ $1 = "-bootclasspath" ]
  then
    BOOTCLASSPATH=$2:$BOOTCLASSPATH
    shift
    shift
    continue
  fi
  OPTIONS="$OPTIONS $1"
  shift
done
GIJ_EXECUTABLE=$(ls /opt/local/bin/gij* | tail -n1)
if [ -e /usr/bin/java ]
then
  exec /usr/bin/java -jar /opt/local/share/java/eclipse-ecj.jar -bootclasspath $BOOTCLASSPATH $OPTIONS
elif [ -e /usr/bin/cacao ]
then
  exec /usr/bin/cacao -jar /opt/local/share/java/eclipse-ecj.jar -bootclasspath $BOOTCLASSPATH $OPTIONS
elif [ -e  ]
then
  exec $GIJ_EXECUTABLE -jar /opt/local/share/java/eclipse-ecj.jar -bootclasspath $BOOTCLASSPATH $OPTIONS
else
  echo "no java vm found :("
  exit -1
fi
