#!/bin/sh
set -e

BINDIR=`dirname $0`
if [ -d $BINDIR/../java/jre ]; then
	JAVA="$BINDIR/../java/jre/bin/java"
	JAVAARGS="--add-exports java.desktop/com.apple.eawt=VncViewer"
else
	if [ "$JAVA_HOME" = "" ]; then
		JAVA=java
	else
		JAVA="$JAVA_HOME/bin/java"
	fi
fi
TVNC_JAVADIR=@CMAKE_INSTALL_FULL_JAVADIR@
if [ -d $BINDIR/../java ]; then
	TVNC_JAVADIR=$BINDIR/../java
fi

exec "$JAVA" $JAVAARGS -server -Djava.library.path=$TVNC_JAVADIR -jar $TVNC_JAVADIR/VncViewer.jar ${1+"$@"}
