#!/bin/sh

ADLIB=@prefix@

if [ $# -lt 1 ]
then
  echo "Usage: prunjava [-t] <procnum> <classname> <options>"
  exit 1
fi

if [ $1 = -t ] 
then 
  TESTMODE=1
  shift
fi

PNUMBER=$1
shift

CLASSNAME=$1
shift

cat > JavaStarter <<EOF
#!/bin/sh

JAVA=@JAVA@

CLASSPATH=.:$JAVA/class:$JAVA/lib/classes.zip:/tmp_mnt/project/kyk20/pcrc/zgs/Project/java/Adlib/src/adJava
export CLASSPATH

LD_LIBRARY_PATH=/tmp_mnt/project/kyk20/pcrc/zgs/Project/java/Adlib/src/adJava/adlib
export LD_LIBRARY_PATH

#echo \$0
cd \`dirname \$0\`

#java $CLASSNAME \$0 \$* # why stater ?
java $CLASSNAME $CLASSNAME \$*

EOF

chmod a+x JavaStarter

if [ $TESTMODE = 1 ]
then 
  $ADLIB/bin/prun -t $PNUMBER JavaStarter $*  
else
  $ADLIB/bin/prun $PNUMBER JavaStarter $*
fi

rm -f JavaStarter
