Could not find or load main class org.apache.hadoop.util.VersionInfo Could not find or load main class org.apache.hadoop.util.VersionInfo hadoop hadoop

Could not find or load main class org.apache.hadoop.util.VersionInfo


It is a problem of environmental variables setup. Apparently, I didnt find one which can work until NOW. I was trying on 2.6.4. Here is what we should do

export HADOOP_HOME=/home/centos/HADOOP/hadoop-2.6.4export HADOOP_INSTALL=$HADOOP_HOMEexport HADOOP_MAPRED_HOME=$HADOOP_HOMEexport HADOOP_COMMON_HOME=$HADOOP_HOMEexport HADOOP_HDFS_HOME=$HADOOP_HOMEexport YARN_HOME=$HADOOP_HOMEexport HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/nativeexport PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/binexport HADOOP_CONF_DIR=$HADOOP_HOMEexport HADOOP_PREFIX=$HADOOP_HOMEexport HADOOP_LIBEXEC_DIR=$HADOOP_HOME/libexecexport JAVA_LIBRARY_PATH=$HADOOP_HOME/lib/native:$JAVA_LIBRARY_PATHexport HADOOP_CONF_DIR=$HADOOP_PREFIX/etc/hadoop

Add these into your .bashrc and dont forget to do

source ~/.bashrc

I think your problem will be solved as was mine.


You probably did not follow the instructions correctly. Here are some things to try and help us / you diagnose this:

  • In the shell that you ran hadoop version, run export and show us the list of relevant environment variables.

  • Show us what you put in the /usr/local/hadoop/etc/hadoop/hadoop-env.sh file.

  • If neither of the above gives you / us any clues, then find and use a text editor to (temporarily) modify the hadoop wrapper shell script. Add the line "set -xv" somewhere near the beginning. Then run hadoop version, and show us what it produces.


Adding this line to ~/.bash_profile worked for me.

export HADOOP_PREFIX=/<where ever you install hadoop>/hadoop

So just:

  1. $ sudo open ~/.bash_profile then add the aforesaid line
  2. $ source ~/.bash_profile

Hope this helps (: