#!/bin/sh
prefix=`dirname $(readlink -f $0 || echo $0)`

# Check whether or not to use the bundled JDK
if [ -d "${prefix}/jdk-17" ]; then
    echo echo "Using bundled JDK."
    JAVA_HOME="${prefix}/jdk-17"
    PATH=$JAVA_HOME/bin:$PATH
else
    echo "Using system JDK."
    java -version
fi

# Check if there is a user-specified Java arguments file
if [ -e "$HOME/.igv/java_arguments" ]; then
    java -showversion --module-path="${prefix}/lib" -Xmx1500m \
        @${prefix}/igv.args \
        -Dsun.java2d.uiScale=2 \
        @"$HOME/.igv/java_arguments" \
        --module=org.igv/org.broad.igv.tools.IgvTools  gui
else
    java -showversion --module-path="${prefix}/lib" -Xmx1500m \
        @${prefix}/igv.args \
        -Dsun.java2d.uiScale=2 \
        --module=org.igv/org.broad.igv.tools.IgvTools  gui
fi
