blob: 699707896b53e868c39fdc70b6e6cabc939ed90d [file] [log] [blame]
buyingyi98e9a9b2013-03-10 21:24:35 +00001#!/bin/sh
2# ----------------------------------------------------------------------------
3# Copyright 2001-2006 The Apache Software Foundation.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# ----------------------------------------------------------------------------
17#
18# Copyright (c) 2001-2006 The Apache Software Foundation. All rights
19# reserved.
20
21
22# resolve links - $0 may be a softlink
23PRG="$0"
24
25while [ -h "$PRG" ]; do
26 ls=`ls -ld "$PRG"`
27 link=`expr "$ls" : '.*-> \(.*\)$'`
28 if expr "$link" : '/.*' > /dev/null; then
29 PRG="$link"
30 else
31 PRG=`dirname "$PRG"`/"$link"
32 fi
33done
34
35PRGDIR=`dirname "$PRG"`
36BASEDIR=`cd "$PRGDIR/.." >/dev/null; pwd`
37
38
39
40# OS specific support. $var _must_ be set to either true or false.
41cygwin=false;
42darwin=false;
43case "`uname`" in
44 CYGWIN*) cygwin=true ;;
45 Darwin*) darwin=true
46 if [ -z "$JAVA_VERSION" ] ; then
47 JAVA_VERSION="CurrentJDK"
48 else
49 echo "Using Java version: $JAVA_VERSION"
50 fi
51 if [ -z "$JAVA_HOME" ] ; then
52 JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
53 fi
54 ;;
55esac
56
57if [ -z "$JAVA_HOME" ] ; then
58 if [ -r /etc/gentoo-release ] ; then
59 JAVA_HOME=`java-config --jre-home`
60 fi
61fi
62
63# For Cygwin, ensure paths are in UNIX format before anything is touched
64if $cygwin ; then
65 [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
66 [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
67fi
68
69# If a specific java binary isn't specified search for the standard 'java' binary
70if [ -z "$JAVACMD" ] ; then
71 if [ -n "$JAVA_HOME" ] ; then
72 if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 # IBM's JDK on AIX uses strange locations for the executables
74 JAVACMD="$JAVA_HOME/jre/sh/java"
75 else
76 JAVACMD="$JAVA_HOME/bin/java"
77 fi
78 else
79 JAVACMD=`which java`
80 fi
81fi
82
83if [ ! -x "$JAVACMD" ] ; then
84 echo "Error: JAVA_HOME is not defined correctly." 1>&2
85 echo " We cannot execute $JAVACMD" 1>&2
86 exit 1
87fi
88
89if [ -z "$REPO" ]
90then
91 REPO="$BASEDIR"/lib
92fi
93
94CLASSPATH=$CLASSPATH_PREFIX:"$HADOOP_HOME"/conf:"$BASEDIR"/etc:$1
95
96# For Cygwin, switch paths to Windows format before running java
97if $cygwin; then
98 [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
99 [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
100 [ -n "$HOME" ] && HOME=`cygpath --path --windows "$HOME"`
101 [ -n "$BASEDIR" ] && BASEDIR=`cygpath --path --windows "$BASEDIR"`
102 [ -n "$REPO" ] && REPO=`cygpath --path --windows "$REPO"`
103fi
104
105exec "$JAVACMD" $JAVA_OPTS \
106 -classpath "$CLASSPATH" \
107 -Dapp.name="pregelix" \
108 -Dapp.pid="$$" \
109 -Dapp.repo="$REPO" \
110 -Dapp.home="$BASEDIR" \
111 -Dbasedir="$BASEDIR" \
112 org.apache.hadoop.util.RunJar \
113 "$@"