#! /bin/sh
# Uncomment the following line to override the JVM search sequence
# INSTALL4J_JAVA_HOME_OVERRIDE=
# Uncomment the following line to add additional VM parameters
# INSTALL4J_ADD_VM_PARAMS=
read_db_entry() {
if [ -n "$INSTALL4J_NO_DB" ]; then
return 1
fi
db_file=$HOME/.install4j
if [ ! -f "$db_file" ]; then
return 1
fi
if [ ! -x "$java_exc" ]; then
return 1
fi
found=1
exec 7< $db_file
while read r_type r_dir r_ver_major r_ver_minor r_ver_micro r_ver_patch<&7; do
if [ "$r_type" = "JRE_VERSION" ]; then
if [ "$r_dir" = "$test_dir" ]; then
ver_major=$r_ver_major
ver_minor=$r_ver_minor
ver_micro=$r_ver_micro
ver_patch=$r_ver_patch
found=0
break
fi
fi
done
exec 7<&-
return $found
}
create_db_entry() {
tested_jvm=true
echo testing JVM in $test_dir ...
version_output=`"$bin_dir/java" -version 2>&1`
is_gcj=`expr "$version_output" : '.*gcj'`
if [ "$is_gcj" = "0" ]; then
java_version=`expr "$version_output" : '.*"\(.*\)".*'`
ver_major=`expr "$java_version" : '\([0-9][0-9]*\)\..*'`
ver_minor=`expr "$java_version" : '[0-9][0-9]*\.\([0-9][0-9]*\)\..*'`
ver_micro=`expr "$java_version" : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`
ver_patch=`expr "$java_version" : '.*_\(.*\)'`
fi
if [ "$ver_patch" = "" ]; then
ver_patch=0
fi
if [ -n "$INSTALL4J_NO_DB" ]; then
return
fi
db_new_file=${db_file}_new
if [ -f "$db_file" ]; then
awk '$1 != "'"$test_dir"'" {print $0}' $db_file > $db_new_file
rm $db_file
mv $db_new_file $db_file
fi
dir_escaped=`echo "$test_dir" | sed -e 's/ /\\\\ /g'`
echo "JRE_VERSION $dir_escaped $ver_major $ver_minor $ver_micro $ver_patch" >> $db_file
}
test_jvm() {
tested_jvm=na
test_dir=$1
bin_dir=$test_dir/bin
java_exc=$bin_dir/java
if [ -z "$test_dir" ] || [ ! -d "$bin_dir" ] || [ ! -f "$java_exc" ] || [ ! -x "$java_exc" ]; then
return
fi
tested_jvm=false
read_db_entry || create_db_entry
if [ "$ver_major" = "" ]; then
return;
fi
if [ "$ver_major" -lt "1" ]; then
return;
elif [ "$ver_major" -eq "1" ]; then
if [ "$ver_minor" -lt "4" ]; then
return;
elif [ "$ver_minor" -eq "4" ]; then
if [ "$ver_micro" -lt "1" ]; then
return;
fi
fi
fi
if [ "$ver_major" = "" ]; then
return;
fi
if [ "$ver_major" -gt "1" ]; then
return;
elif [ "$ver_major" -eq "1" ]; then
if [ "$ver_minor" -gt "6" ]; then
return;
fi
fi
app_java_home=$test_dir
}
add_class_path() {
if [ -n "$1" ] && [ `expr "$1" : '.*\*'` -eq "0" ]; then
local_classpath="$local_classpath${local_classpath:+:}$1"
fi
}
old_pwd=`pwd`
progname=`basename "$0"`
linkdir=`dirname "$0"`
cd "$linkdir"
prg="$progname"
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
prg_dir=`dirname "$prg"`
progname=`basename "$prg"`
cd "$prg_dir"
prg_dir=`pwd`
app_home=.
cd "$app_home"
app_home=`pwd`
bundled_jre_home="$app_home/jre"
if [ "__i4j_lang_restart" = "$1" ]; then
cd "$old_pwd"
else
cd "$prg_dir"/.
gunzip -V > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "Sorry, but I could not find gunzip in path. Aborting."
cd "$old_pwd"
rm -R -f "$sfx_dir_name"
exit 1
fi
sfx_dir_name="${progname}.$$.dir"
mkdir "$sfx_dir_name" > /dev/null 2>&1
if [ ! -d "$sfx_dir_name" ]; then
sfx_dir_name="/tmp/${progname}.$$.dir"
mkdir "$sfx_dir_name"
if [ ! -d "$sfx_dir_name" ]; then
echo "Could not create dir $sfx_dir_name. Aborting."
exit 1
fi
fi
cd "$sfx_dir_name"
sfx_dir_name=`pwd`
trap 'cd "$old_pwd"; rm -R -f "$sfx_dir_name"; exit 1' HUP INT QUIT TERM
tail -c 15434850 "$prg_dir/${progname}" > sfx_archive.tar.gz 2> /dev/null
if [ "$?" -ne "0" ]; then
tail -15434850c "$prg_dir/${progname}" > sfx_archive.tar.gz 2> /dev/null
if [ "$?" -ne "0" ]; then
echo "tail didn't work. Aborting."
cd "$old_pwd"
rm -R -f "$sfx_dir_name"
exit 1
fi
fi
gunzip sfx_archive.tar.gz
if [ "$?" -ne "0" ]; then
echo ""
echo "I am sorry, but the installer file seems to be corrupted."
echo "If you downloaded that file please try it again. If you"
echo "transfer that file with ftp please make sure that you are"
echo "using binary mode."
cd "$old_pwd"
rm -R -f "$sfx_dir_name"
exit 1
fi
tar xf sfx_archive.tar > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "Could not untar archive. Aborting."
cd "$old_pwd"
rm -R -f "$sfx_dir_name"
exit 1
fi
fi
if [ ! "__i4j_lang_restart" = "$1" ]; then
if [ -f "$prg_dir/jre.tar.gz" ] && [ ! -f jre.tar.gz ] ; then
cp "$prg_dir/jre.tar.gz" .
fi
if [ -f jre.tar.gz ]; then
echo "Unpacking JRE ..."
gunzip jre.tar.gz
mkdir jre
cd jre
tar xf ../jre.tar
app_java_home=`pwd`
bundled_jre_home="$app_java_home"
cd ..
fi
if [ -f "$bundled_jre_home/lib/rt.jar.pack" ]; then
old_pwd200=`pwd`
cd "$bundled_jre_home"
echo "Preparing JRE ..."
jar_files="lib/rt.jar lib/charsets.jar lib/plugin.jar lib/deploy.jar lib/ext/localedata.jar lib/jsse.jar"
for jar_file in $jar_files
do
if [ -f "${jar_file}.pack" ]; then
bin/unpack200 -r ${jar_file}.pack $jar_file
if [ $? -ne 0 ]; then
echo "Error unpacking jar files. Aborting."
echo "You might need administrative priviledges for this operation."
cd "$old_pwd"
rm -R -f "$sfx_dir_name"
exit 1
fi
fi
done
cd "$old_pwd200"
fi
else
if [ -d jre ]; then
app_java_home=`pwd`
app_java_home=$app_java_home/jre
fi
fi
if [ -z "$app_java_home" ]; then
test_jvm $INSTALL4J_JAVA_HOME_OVERRIDE
fi
if [ -z "$app_java_home" ]; then
if [ -f "$app_home/.install4j/pref_jre.cfg" ]; then
read file_jvm_home < "$app_home/.install4j/pref_jre.cfg"
test_jvm "$file_jvm_home"
if [ -z "$app_java_home" ] && [ $tested_jvm = "false" ]; then
rm $HOME/.install4j
test_jvm "$file_jvm_home"
fi
fi
fi
if [ -z "$app_java_home" ]; then
test_jvm $JPROFILER_JAVA_HOME
fi
if [ -z "$app_java_home" ]; then
path_java=`which java 2> /dev/null`
path_java_home=`expr "$path_java" : '\(.*\)/bin/java$'`
test_jvm $path_java_home
fi
if [ -z "$app_java_home" ]; then
common_jvm_locations="/opt/i4j_jres/* /usr/local/i4j_jres/* $HOME/.i4j_jres/* /usr/bin/java* /usr/bin/jdk* /usr/bin/jre* /usr/bin/j2*re* /usr/bin/j2sdk* /usr/java* /usr/jdk* /usr/jre* /usr/j2*re* /usr/j2sdk* /usr/java/j2*re* /usr/java/j2sdk* /opt/java* /usr/java/jdk* /usr/java/jre* /usr/lib/java/jre /usr/local/java* /usr/local/jdk* /usr/local/jre* /usr/local/j2*re* /usr/local/j2sdk* /usr/jdk/java* /usr/jdk/jdk* /usr/jdk/jre* /usr/jdk/j2*re* /usr/jdk/j2sdk* /usr/lib/java* /usr/lib/jdk* /usr/lib/jre* /usr/lib/j2*re* /usr/lib/j2sdk*"
for current_location in $common_jvm_locations
do
if [ -z "$app_java_home" ]; then
test_jvm $current_location
fi
done
fi
if [ -z "$app_java_home" ]; then
test_jvm $JAVA_HOME
fi
if [ -z "$app_java_home" ]; then
test_jvm $JDK_HOME
fi
if [ -z "$app_java_home" ]; then
test_jvm /opt/java1.5/
fi
if [ -z "$app_java_home" ]; then
test_jvm /opt/java1.4/
fi
if [ -z "$app_java_home" ]; then
test_jvm $INSTALL4J_JAVA_HOME
fi
if [ -z "$app_java_home" ]; then
if [ -f "$app_home/.install4j/inst_jre.cfg" ]; then
read file_jvm_home < "$app_home/.install4j/inst_jre.cfg"
test_jvm "$file_jvm_home"
if [ -z "$app_java_home" ] && [ $tested_jvm = "false" ]; then
rm $HOME/.install4j
test_jvm "$file_jvm_home"
fi
fi
fi
if [ -z "$app_java_home" ]; then
echo No suitable Java Virtual Machine could be found on your system.
echo The version of the JVM must be at least 1.4.1 and at most 1.6.
echo Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.
echo You can also try to delete the JVM cache file $HOME/.install4j
cd "$old_pwd"
rm -R -f "$sfx_dir_name"
exit 83
fi
i4j_classpath="i4jruntime.jar:user.jar"
local_classpat