Search
j0ke.net Open Build Service
>
Projects
>
Java
>
jpackage-utils
> javawrapper
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File javawrapper of Package jpackage-utils
#!/bin/bash # /usr/local/bin/javawrapper - the wrapper for binfmt_misc/java if [ $# -lt 1 ] then echo "Use this program to execute a Java class file, usage:" echo -e "\t$0 <jar file>.class" exit 1; fi CLASS=$1 FQCLASS=`/usr/bin/javaclassname $1` FQCLASSN=`echo $FQCLASS | sed -e 's/^.*\.\([^.]*\)$/\1/'` FQCLASSP=`echo $FQCLASS | sed -e 's-\.-/-g' -e 's-^[^/]*$--' -e 's-/[^/]*$--'` # for example: # CLASS=Test.class # FQCLASS=foo.bar.Test # FQCLASSN=Test # FQCLASSP=foo/bar unset CLASSBASE declare -i LINKLEVEL=0 while :; do if [ "`basename $CLASS .class`" == "$FQCLASSN" ]; then # See if this directory works straight off cd -L `dirname $CLASS` CLASSDIR=$PWD cd $OLDPWD if echo $CLASSDIR | grep -q "$FQCLASSP$"; then CLASSBASE=`echo $CLASSDIR | sed -e "s.$FQCLASSP$.."` break; fi # Try dereferencing the directory name cd -P `dirname $CLASS` CLASSDIR=$PWD cd $OLDPWD if echo $CLASSDIR | grep -q "$FQCLASSP$"; then CLASSBASE=`echo $CLASSDIR | sed -e "s.$FQCLASSP$.."` break; fi # If no other possible filename exists if [ ! -L $CLASS ]; then exec 1>&2 echo $0: echo " $CLASS should be in a" \ "directory tree called $FQCLASSP" exit 1 fi fi if [ ! -L $CLASS ]; then break; fi # Go down one more level of symbolic links let LINKLEVEL+=1 if [ $LINKLEVEL -gt 5 ]; then exec 1>&2 echo $0: echo " Too many symbolic links encountered" exit 1 fi CLASS=`ls --color=no -l $CLASS | sed -e 's/^.* \([^ ]*\)$/\1/'` done if [ -z "$CLASSBASE" ]; then if [ -z "$FQCLASSP" ]; then GOODNAME=$FQCLASSN.class else GOODNAME=$FQCLASSP/$FQCLASSN.class fi exec 1>&2 echo $0: echo " $FQCLASS should be in a file called $GOODNAME" exit 1 fi if ! echo $CLASSPATH | grep -q "^\(.*:\)*$CLASSBASE\(:.*\)*"; then # class is not in CLASSPATH, so prepend dir of class to CLASSPATH if [ -z "${CLASSPATH}" ] ; then export CLASSPATH=$CLASSBASE else export CLASSPATH=$CLASSBASE:$CLASSPATH fi fi shift if [ ! -x $1 ] then if which kdialog then kdialog --error "$1 does not have execute permission ... please fix" elif which zenity then zenity --error --text="$1 does not have execute permission ... please fix" else echo "$1 does not have execute permission ... please fix" echo read fi exit 1 fi echo "executing:" echo -e "\t/usr/bin/java $FQCLASS \"$@\":" echo echo if ! /usr/bin/java $FQCLASS "$@" then echo "The execution of $1 failed. The reason is probably that $1 does not contain a main method " echo "The class was called as follows:" echo " /usr/bin/java $FQCLASS \"$@\"" fi echo Press key to exit ... read