1#!/bin/sh 2# 3# Copyright (C) 2017 and later: Unicode, Inc. and others. 4# License & terms of use: http://www.unicode.org/copyright.html 5# 6# Copyright (c) 2008-2013 IBM Corp. and Others. All Rights Reserved 7if [ ! -x $1 ]; 8then 9 echo usage: $0 path/to/bin/java 10 exit 1 11fi 12 13if ! $1 -version > /dev/null ; 14then 15 echo could not run $1 16 exit 2 17fi 18 19if ! ( $1 -version 2>&1 | grep -q "java version" ); 20then 21 echo could not get java version from $1 22 exit 3 23fi 24 25VER=`$1 -version 2>&1 | grep "java version" | head -1 | sed -e 's%^java version "\([^"]*\)\".*$%\1%'` 26VERD=`echo $VER | tr . _` 27 28echo $1 = $VER / $VERD 29 30FILE="$VERD.sh" 31 32if [ -f $FILE ]; 33then 34 FILE="${VERD}_$$.sh" 35 echo "$VERD.sh existed, renaming to $FILE - rename to something sane if you want" 36fi 37 38JHOME=`dirname $1` 39JHOME=`dirname $JHOME` 40 41echo "#!/bin/sh" > $FILE 42echo "# auto generated for $VER from $1 / addjava.sh" >> $FILE 43echo "JAVA_HOME=$JHOME" >> $FILE 44echo >> $FILE 45echo >> $FILE 46$1 -version 2>&1 | sed -e 's%^%#%' >> $FILE 47 48chmod a+rx $FILE 49 50echo 51echo "Created: $FILE" 52 53 54 55 56 57