#!/bin/sh # # Runs Processing, using an already installed JDK if possible. # Otherwise, falls back to the local JDK that comes with Processing. # # JARs required from JDK (anywhere in/below the JDK home directory) JDKLIBS="rt.jar tools.jar" # Locates the required JARs in JDKDIR and saves them in JDKCP. Sets # SUCCESS to 1 if all JARs were found, to 0 otherwise. make_jdkcp() { unset JDKCP SUCCESS=1 for L in $JDKLIBS; do # Use the first JAR with a matching relative path LIB=`find "$JDKDIR" -name $L | head -n 1` JDKCP=${JDKCP+"$JDKCP":}"$LIB" [ -z "$LIB" ] && SUCCESS=0 done } # Get absolute path of directory where this script is located APPDIR=`readlink -f "$0"` APPDIR=`dirname "$APPDIR"` # Locate preferred system JRE/JDK home JDKDIR=`which java` && JDKDIR=`readlink -e "$JDKDIR"` && JDKDIR=`dirname "$JDKDIR"`/.. # Back out of JRE directory if apparently located inside another JDK if [ -f "$JDKDIR/../bin/java" ]; then JDKDIR="$JDKDIR/.." fi # Locate required JARs in JDK home make_jdkcp # Suitable system JDK found? if [ $SUCCESS -ne 1 ]; then # No, use local JDK installation JDKDIR="$APPDIR/java" make_jdkcp fi # Add all required JARs to CLASSPATH CLASSPATH="$CLASSPATH":"$JDKCP" for LIB in "$APPDIR"/lib/*.jar; do CLASSPATH="$CLASSPATH":"$LIB" done export CLASSPATH # Make all JDK binaries available in PATH export PATH="$JDKDIR/bin":"$PATH" # Start Processing in the same directory as this script cd "$APPDIR" java processing.app.Base