#!/bin/sh
#
# File:		jswat
# Purpose:	jswat application startup script
# Author:	crafterm@debian.org
# Date:		4 October 2001
# Usage:	jswat [-h] [-sp sourcepath] [-cp classpath] [jvm arg] [class]
#		-h or --help        : Display this help message
#		-sp or --sourcepath : Set source path for locating source files
#		-cp or --classpath  : Specify debugged JVM classpath
#		jvm arg             : Arguments to pass to jvm being debugged
#		class               : Class to debugged
#
# Note, all parameters listed above can also be specified via jswat's
# 'Debug->Start' VM dialog.
#

#
# This script is licensed under the same terms as jswat itself
#

# Declare local functions
showhelp()
{
	head -16 $0			# display help
	exit 1
}

# Process command line arguments
for args in $*
do
	case $args in

		# Display help if the user asks for it
		"-h"|"--help") showhelp ;;

		# Specify source path
		"-sp"|"--sourcepath") SOURCES=$2; shift 2 ;;

		# Specify target JVM classpath
		"-cp"|"--classpath") CP=$2; shift 2 ;;
	esac
done

# Setup classpath
CLASSPATH=$CLASSPATH:$CP:/usr/share/java/jswat-1.7.jar:/usr/share/java/jswat-parser-1.7.jar

if [ "$JAVA_HOME" != "" ] ; then
  if [ -f $JAVA_HOME/lib/tools.jar ] ; then
    CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar
  fi
fi

export CLASSPATH

# Execute JSWAT
exec /usr/bin/java -Djava.source.path="$SOURCES" com.bluemarsh.jswat.Main $@
