Skip to content

Commit

Permalink
Added support for JAVA_HOME and -D java opts.
Browse files Browse the repository at this point in the history
  • Loading branch information
dstreev committed Sep 24, 2020
1 parent f843c67 commit 7282460
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion bin/hadoopcli
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ fi
PRG_ARGS=
CMD_CP=

if [ ! -z ${JAVA_HOME} ]; then
JAVA="${JAVA_HOME}/bin/java"
else
JAVA=java
fi

if [[ -f ./hadoop-cli-shaded.jar ]]; then
# Look in Current Directory
CMD_CP=$APP_DIR/hadoop-cli-shaded.jar
Expand Down Expand Up @@ -43,6 +49,7 @@ CMD_DIRECTIVE=
CMD_ARGS=
VERBOSE=
ENV_VAR_FILE=
APP_JAVA_OPTS=

if [[ -f ${HOME}/.hadoop-cli/env-var.props || -L ${HOME}/.hadoop-cli/env-var.props ]]; then
ENV_VAR_FILE=${HOME}/.hadoop-cli/env-var.props
Expand All @@ -54,6 +61,10 @@ fi

while [[ $# -gt 0 ]]; do
case "$1" in
-D*)
APP_JAVA_OPTS="${APP_JAVA_OPTS} ${1}"
shift
;;
-i|--init)
shift
PRG_ARGS="${PRG_ARGS} -i \"${1}\""
Expand Down Expand Up @@ -149,6 +160,15 @@ if [[ "${SHOW_CP}x" != "x" ]]; then
echo "Program args: ${PRG_ARGS}"
fi

CLI_CMD="${CLI_CMD}java -cp ${CMD_CP} com.streever.hadoop.HadoopShell ${PRG_ARGS}"
if [[ "${APP_JAVA_OPTS}x" != "x" ]]; then
echo "Application JAVA_OPTS=${APP_JAVA_OPTS}"
fi

JV=$(${JAVA} -version)

echo "Using Java Version: "
echo $JV

CLI_CMD="${JAVA} -cp ${CMD_CP} ${APP_JAVA_OPTS} com.streever.hadoop.HadoopShell ${PRG_ARGS}"

eval "${CLI_CMD}"
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.streever.hadoop</groupId>
<artifactId>hadoop-cli</artifactId>
<version>2.2.2.0-SNAPSHOT</version>
<version>2.2.2.1-SNAPSHOT</version>
<name>Hadoop CLI</name>
<description>Hadoop Command Line Interface</description>
<properties>
Expand Down

0 comments on commit 7282460

Please sign in to comment.