+case "$jpctbdir" in
+/*) ;;
+*) jpctbdir="$PWD/$jpctbdir" ;;
+esac
+
+if [ x"$srcjardir" = x ]; then
+ srcjardir="$jpctbdir"
+fi
+
+#---------- find YPP client and the Java installation it uses ----------
+
+yppdir="${yohoho%/*}"
+
+openjdk=/usr/lib/jvm/java-6-openjdk
+
+if [ -x "$yppdir/java/bin/java" ]; then
+ javadir="$yppdir/java"
+elif [ x"$JAVA_HOME" != x ] && [ -x "$JAVA_HOME/bin/java" ]; then
+ javadir="$JAVA_HOME"
+elif [ -x $openjdk/bin/java ]; then
+ javadir=$openjdk
+else
+ fail "could not find java runtime system
+ please check that $yppdir/java points to your Java installation"
+fi
+
+case "$javadir" in
+/*) ;;
+*) javadir="$PWD/$javadir" ;;
+esac
+
+jtmp="$jpctbdir/tmp"
+linkfarm="$jtmp/linkfarm"
+extdir="$jtmp/ext"
+
+#---------- confirm for the user which paths we're using ----------
+
+cat <<END
+jpctb:
+ jpctb tree: "$jpctbdir"
+ yohoho: "$yohoho"
+ java: "$javadir"
+ PCTB jars: "$srcjardir"
+ jpctb tmpdir: "$jtmp"
+END
+
+#---------- run the control panel ----------
+
+"$javadir/bin/java" -jar "$srcjardir/PCTB-ControlPanel.jar"
+
+#---------- create the temporary are and link farm ----------
+
+rm -rf -- "$jtmp"
+mkdir -- "$jtmp" "$extdir" "$linkfarm"
+cp "$srcjardir"/PCTB*.jar "$extdir"
+
+lndir -silent "$javadir" "$linkfarm"
+
+#---------- edit the linkfarm to have our jvm wrapper ----------
+
+wrapper="$linkfarm"/jre/bin/java
+rm -- "$wrapper"
+
+export JPCTB_EXTDIR="$extdir"
+export JPCTB_JRE="$javadir/jre"
+
+cat <<'END' >"$wrapper"
+#!/bin/bash
+ set -e$JPCTB_JWRAP_X
+
+ log () {
+ lh=`date +'%Y/%m/%d %H:%M:%S jpctb'`
+ printf >&2 "%s: %s |\f\n" "$lh" "$*"
+ }
+
+ log "invoked as $*"
+
+#echo >&2 "$djava-wrap
+#exec 4>>/home/ian/u
+#date >&4
+#exec 4>&-
+
+ yppclass=com.threerings.yohoho.client.YoApp
+ atclass=com.tedpearson.ypp.market.MarketUploader
+
+ args=( "$@" )
+ nargs=${#args[*]}
+ lastarg="${args[$(( $nargs - 1 ))]}"
+
+ fail () { echo >&2 "jpctb-java: $*"; exit 127; }
+
+ if [ x"$lastarg" = x"$yppclass" ]; then
+
+ [ x"$JPCTB_EXTDIR" != x ] || fail 'JPCTB_EXTDIR not set'
+
+ set -e$JPCTB_JWRAP_X -- \
+ -Djavax.accessibility.assistive_technologies=$atclass \
+ -Djava.ext.dirs="$JPCTB_EXTDIR:$JPCTB_JRE/lib/ext" \
+ "$@"
+ fi
+
+ real="$JPCTB_JRE/bin/java"
+ log "running $real $*"
+ exec "$real" "$@"
+END