| 1 | #!/bin/sh | 
|---|
| 2 |  | 
|---|
| 3 | # Licensed to the Apache Software Foundation (ASF) under one or more | 
|---|
| 4 | # contributor license agreements.  See the NOTICE file distributed with | 
|---|
| 5 | # this work for additional information regarding copyright ownership. | 
|---|
| 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 | 
|---|
| 7 | # (the "License"); you may not use this file except in compliance with | 
|---|
| 8 | # the License.  You may obtain a copy of the License at | 
|---|
| 9 | # | 
|---|
| 10 | #     http://www.apache.org/licenses/LICENSE-2.0 | 
|---|
| 11 | # | 
|---|
| 12 | # Unless required by applicable law or agreed to in writing, software | 
|---|
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, | 
|---|
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|---|
| 15 | # See the License for the specific language governing permissions and | 
|---|
| 16 | # limitations under the License. | 
|---|
| 17 |  | 
|---|
| 18 | # ----------------------------------------------------------------------------- | 
|---|
| 19 | #  Set CLASSPATH and Java options | 
|---|
| 20 | # | 
|---|
| 21 | #  $Id: setclasspath.sh 589060 2007-10-27 08:19:24Z jfclere $ | 
|---|
| 22 | # ----------------------------------------------------------------------------- | 
|---|
| 23 |  | 
|---|
| 24 | # First clear out the user classpath | 
|---|
| 25 | CLASSPATH= | 
|---|
| 26 |  | 
|---|
| 27 | # Make sure prerequisite environment variables are set | 
|---|
| 28 | if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then | 
|---|
| 29 | # Bugzilla 37284 (reviewed). | 
|---|
| 30 | if $darwin; then | 
|---|
| 31 | if [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" ]; then | 
|---|
| 32 | export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" | 
|---|
| 33 | fi | 
|---|
| 34 | else | 
|---|
| 35 | JAVA_PATH=`which java 2>/dev/null` | 
|---|
| 36 | if [ "x$JAVA_PATH" != "x" ]; then | 
|---|
| 37 | JAVA_PATH=`dirname $JAVA_PATH 2>/dev/null` | 
|---|
| 38 | JRE_HOME=`dirname $JAVA_PATH 2>/dev/null` | 
|---|
| 39 | fi | 
|---|
| 40 | if [ "x$JRE_HOME" = "x" ]; then | 
|---|
| 41 | # XXX: Should we try other locations? | 
|---|
| 42 | if [ -x /usr/bin/java ]; then | 
|---|
| 43 | JRE_HOME=/usr | 
|---|
| 44 | fi | 
|---|
| 45 | fi | 
|---|
| 46 | fi | 
|---|
| 47 | if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then | 
|---|
| 48 | echo "Neither the JAVA_HOME nor the JRE_HOME environment variable is defined" | 
|---|
| 49 | echo "At least one of these environment variable is needed to run this program" | 
|---|
| 50 | exit 1 | 
|---|
| 51 | fi | 
|---|
| 52 | fi | 
|---|
| 53 | if [ -z "$JAVA_HOME" -a "$1" = "debug" ]; then | 
|---|
| 54 | echo "JAVA_HOME should point to a JDK in order to run in debug mode." | 
|---|
| 55 | exit 1 | 
|---|
| 56 | fi | 
|---|
| 57 | if [ -z "$JRE_HOME" ]; then | 
|---|
| 58 | JRE_HOME="$JAVA_HOME" | 
|---|
| 59 | fi | 
|---|
| 60 |  | 
|---|
| 61 | # If we're running under jdb, we need a full jdk. | 
|---|
| 62 | if [ "$1" = "debug" -o "$1" = "javac" ] ; then | 
|---|
| 63 | if [ "$os400" = "true" ]; then | 
|---|
| 64 | if [ ! -x "$JAVA_HOME"/bin/java -o ! -x "$JAVA_HOME"/bin/javac ]; then | 
|---|
| 65 | echo "The JAVA_HOME environment variable is not defined correctly" | 
|---|
| 66 | echo "This environment variable is needed to run this program" | 
|---|
| 67 | echo "NB: JAVA_HOME should point to a JDK not a JRE" | 
|---|
| 68 | exit 1 | 
|---|
| 69 | fi | 
|---|
| 70 | else | 
|---|
| 71 | if [ ! -x "$JAVA_HOME"/bin/java -o ! -x "$JAVA_HOME"/bin/jdb -o ! -x "$JAVA_HOME"/bin/javac ]; then | 
|---|
| 72 | echo "The JAVA_HOME environment variable is not defined correctly" | 
|---|
| 73 | echo "This environment variable is needed to run this program" | 
|---|
| 74 | echo "NB: JAVA_HOME should point to a JDK not a JRE" | 
|---|
| 75 | exit 1 | 
|---|
| 76 | fi | 
|---|
| 77 | fi | 
|---|
| 78 | fi | 
|---|
| 79 | if [ -z "$BASEDIR" ]; then | 
|---|
| 80 | echo "The BASEDIR environment variable is not defined" | 
|---|
| 81 | echo "This environment variable is needed to run this program" | 
|---|
| 82 | exit 1 | 
|---|
| 83 | fi | 
|---|
| 84 | if [ ! -x "$BASEDIR"/bin/setclasspath.sh ]; then | 
|---|
| 85 | if $os400; then | 
|---|
| 86 | # -x will Only work on the os400 if the files are: | 
|---|
| 87 | # 1. owned by the user | 
|---|
| 88 | # 2. owned by the PRIMARY group of the user | 
|---|
| 89 | # this will not work if the user belongs in secondary groups | 
|---|
| 90 | eval | 
|---|
| 91 | else | 
|---|
| 92 | echo "The BASEDIR environment variable is not defined correctly" | 
|---|
| 93 | echo "This environment variable is needed to run this program" | 
|---|
| 94 | exit 1 | 
|---|
| 95 | fi | 
|---|
| 96 | fi | 
|---|
| 97 |  | 
|---|
| 98 | # Set the default -Djava.endorsed.dirs argument | 
|---|
| 99 | JAVA_ENDORSED_DIRS="$BASEDIR"/endorsed | 
|---|
| 100 |  | 
|---|
| 101 | # Set standard CLASSPATH | 
|---|
| 102 | if [ "$1" = "javac" ] ; then | 
|---|
| 103 | if [ ! -f "$JAVA_HOME"/lib/tools.jar ]; then | 
|---|
| 104 | echo "Can't find tools.jar in JAVA_HOME" | 
|---|
| 105 | echo "Need a JDK to run javac" | 
|---|
| 106 | exit 1 | 
|---|
| 107 | fi | 
|---|
| 108 | fi | 
|---|
| 109 | if [ "$1" = "debug" -o "$1" = "javac" ] ; then | 
|---|
| 110 | if [ -f "$JAVA_HOME"/lib/tools.jar ]; then | 
|---|
| 111 | CLASSPATH="$JAVA_HOME"/lib/tools.jar | 
|---|
| 112 | fi | 
|---|
| 113 | fi | 
|---|
| 114 |  | 
|---|
| 115 | # OSX hack to CLASSPATH | 
|---|
| 116 | JIKESPATH= | 
|---|
| 117 | if [ `uname -s` = "Darwin" ]; then | 
|---|
| 118 | OSXHACK="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes" | 
|---|
| 119 | if [ -d "$OSXHACK" ]; then | 
|---|
| 120 | for i in "$OSXHACK"/*.jar; do | 
|---|
| 121 | JIKESPATH="$JIKESPATH":"$i" | 
|---|
| 122 | done | 
|---|
| 123 | fi | 
|---|
| 124 | fi | 
|---|
| 125 |  | 
|---|
| 126 | # Set standard commands for invoking Java. | 
|---|
| 127 | _RUNJAVA="$JRE_HOME"/bin/java | 
|---|
| 128 | if [ "$os400" != "true" ]; then | 
|---|
| 129 | _RUNJDB="$JAVA_HOME"/bin/jdb | 
|---|
| 130 | fi | 
|---|
| 131 | _RUNJAVAC="$JAVA_HOME"/bin/javac | 
|---|