Cool - thanks again!

I'm not much of a shell script guy myself, so I'll post this on the dev list, and if no one squeeks I'll add it to the package :-).

   cheers,

        Chris

On 22/03/2006, at 8:57 PM, Gert Jan Verhoog wrote:

Chris Betts wrote:
that's a good idea - thanks! Of course a lot of systems don't set JAVA_HOME, but it's still worth looking :-).
I made another small change to the shell script, that allows you to start JXplorer even if you're not in JXplorer's directory. I copied a snippet from Apache Tomcat's startup shellscript that determines the directory where the JXplorer shell script is located. The script then starts a subshell where it cd's into the correct directory before starting JXplorer. Even better would be to prepend the full JXplorer directory to all relative classpaths, but I was lazy :-)

The new shell script is attached to this mail.

cheers,
Gert Jan

--
Gert Jan Verhoog
Func. Internet Integration
W http://www.func.nl
T +31 30 2109750
F +31 30 2109751
#!/bin/sh
# OpenDirectory jxstart.sh $Revision: 1.12 $ $Date: 2004/12/16 04:00:13 $

if [ -x $JAVA_HOME/bin/java ]; then
    JAVA_LOC=$JAVA_HOME/bin/java
elif [ -x /opt/jre/bin/java ]; then
    JAVA_LOC=/opt/jre/bin/java
elif [ -x /opt/ca/jre/bin/java ]; then
    JAVA_LOC=/opt/ca/jre/bin/java
elif [ -x /opt/ca/etrustdirectory/jre/bin/java ]; then
    JAVA_LOC=/opt/ca/etrustdirectory/jre/bin/java
elif [ -x /opt/CA/eTrustDirectory/jre/bin/java ]; then
    JAVA_LOC=/opt/CA/eTrustDirectory/jre/bin/java
else
    JAVA_LOC=java
fi

# resolve links - $0 may be a softlink
PRG="$0"

while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '.*/.*' > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done

PRGDIR=`dirname "$PRG"`

# Find directory of JRE
${JAVA_LOC} -version  >/dev/null 2>&1
if [ "$?" != "0" ] ; then
        OPTJX=/opt/jxplorer

# $OPTJX MUST be the JXplorer install directory, or a link to it, and contain the JRE

        if [ ! -d $OPTJX -o ! -h $OPTJX ] ; then
                echo "Either java must be in the path, or"
echo "$OPTJX MUST be the JXplorer install directory, or a link to it, and contain the JRE"
                exit 1
        fi

        cd $OPTJX
        JAVAV=/opt/jxplorer/jre/bin/java
else
        JAVAV=${JAVA_LOC}
fi

echo "starting JXplorer..."
echo
FAIL=0
if [ "$1" = "console" ] ; then
(cd $PRGDIR && $JAVAV -cp .:jars/jxplorer.jar:jars/ help.jar:jars/jhall.jar:jars/junit.jar:jars/ldapsec.jar:jars/ log4j.jar:jars/dsml/activation.jar:jars/dsml/commons- logging.jar:jars/dsml/dom4j.jar:jars/dsml/jxext.jar:jars/dsml/ mail.jar:jars/dsml/providerutil.jar:jars/dsml/saaj-api.jar:jars/ dsml/saaj-ri.jar com.ca.directory.jxplorer.JXplorer)

    if [ "$?" != "0" ]; then
        FAIL=1
    fi
else
echo "Use \"jxstart.sh console\" if you want logging to the console" (cd $PRGDIR && $JAVAV -cp .:jars/jxplorer.jar:jars/ help.jar:jars/jhall.jar:jars/junit.jar:jars/ldapsec.jar:jars/ log4j.jar:jars/dsml/activation.jar:jars/dsml/commons- logging.jar:jars/dsml/dom4j.jar:jars/dsml/jxext.jar:jars/dsml/ mail.jar:jars/dsml/providerutil.jar:jars/dsml/saaj-api.jar:jars/ dsml/saaj-ri.jar com.ca.directory.jxplorer.JXplorer) >/dev/null 2>&1

    if [ "$?" != "0" ]; then
        FAIL=1
    fi
fi

# Check for success
if [ $FAIL = 0 ]; then
    exit 0
fi

cat <<-!

=========================
JXplorer failed to start
=========================
Please ensure that you have appropriate "xhost" access to the machine you are running this from. Make sure the DISPLAY environment variable is set correctly. Otherwise, ask your Unix Systems Administrator for more information on running
X Windows applications.

If you require more information run "$0 console" and check the
error produced.
!

exit 1



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Jxplorer-devel mailing list
Jxplorer-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jxplorer-devel

Reply via email to