#!/bin/sh
### ====================================================================== ###
##                                                                          ##
##  dcm4che2/esoundex2  Launch Script                                         ##
##                                                                          ##
### ====================================================================== ###

### $Id$ ###

MAIN_CLASS=org.dcm4che2.soundex.ESoundex2
MAIN_JAR=dcm4che-soundex-2.0.30-SNAPSHOT.jar

DIRNAME="`dirname "$0"`"

# OS specific support (must be 'true' or 'false').
cygwin=false;
case "`uname`" in
    CYGWIN*)
        cygwin=true
        ;;
esac

# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
    [ -n "$DCM4CHE_HOME" ] &&
        DCM4CHE_HOME=`cygpath --unix "$DCM4CHE_HOME"`
    [ -n "$JAVA_HOME" ] &&
        JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi

# Setup DCM4CHE_HOME
if [ "x$DCM4CHE_HOME" = "x" ]; then
    DCM4CHE_HOME=`cd "$DIRNAME"/..; pwd`
fi

# Setup the JVM
if [ "x$JAVA_HOME" != "x" ]; then
    JAVA=$JAVA_HOME/bin/java
else
    JAVA="java"
fi

# Setup the classpath
CP="$DCM4CHE_HOME/lib/$MAIN_JAR"

# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
    JAVA=`cygpath --path --windows "$JAVA"`
    CP=`cygpath --path --windows "$CP"`
fi

# Execute the JVM
exec $JAVA $JAVA_OPTS -cp "$CP" $MAIN_CLASS "$@"