Reputation: 16628
I executed below command: hadoop -version
on hadoop version 1.2.1
vishrant@ubuntu:~$ hadoop -version java version "1.7.0_79" OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu0.12.04.1) OpenJDK Server VM (build 24.79-b02, mixed mode)
I was expecting hadoop version but I got the version of JDK installed on my system. I know that correct command is hadoop version
[without hyphen] but instead of getting error I got the version of JDK why?
Upvotes: 2
Views: 296
Reputation: 13927
It looks like the hadoop
script for 1.2.x
has much less checking than more recent versions, at this point (2016) its about 3 years old. You can see the source for it here.
In the 1.2.x
script if you type hadoop -version
the script will hit the final else
statement where it works out what class to run and sets $CLASS
to $COMMAND
(line 338) instead of a class.
You can see what it will run on line 434:
exec "$JAVA" -Dproc_$COMMAND $JAVA_HEAP_MAX $HADOOP_OPTS -classpath "$CLASSPATH" $CLASS "$@"
So if you type hadoop version
it will run (removed classpath stuff to keep it short):
java -Dproc_version -Xmx1000m -classpath <LIBS> org.apache.hadoop.util.VersionInfo
If you type hadoop -version
you get:
java -Dproc_-version -Xmx1000m -classpath <LIBS> -version
So because the default behavior is to set $CLASS
to $COMMAND
you basically end up with it running:
java -version
Which is what you're getting.
Upvotes: 2