Q:

Could not find or load main class M - hadoop windows

I am new to hadoop and I am trying to set up hadoop on windows 10. I downloaded the hadoop version 2.7.3 tar.gz from Apache website. These are the steps I have done:

Extracted the tar.gz into a folder in C:\ ---> C:\hadoop
Created and set the HADOOP_HOME environment variable to C:\hadoop
Updated the PATH environment variable by adding C:\hadoop\bin
Added the JAVA_HOME environment variable and set it to the jdk home folder.

The issue is that, any Hadoop related command I execute gives me the following error:

Error: Could not find or load main class M

For example, I get this error even on executing the following command:hadoop version
I read a lot of related posts on stackoverflow, and tried the different suggestions such as updating hadoop-env.sh, hadoop-config.sh, repeated the whole set up process multiple times. The other posts here seem to refer to errors that deal with specific classes, however, the error I face does not provide any class name, it just says class M.
I am not sure what the problem is, and nothing I do seems to work. Could anyone please let me know what is wrong and how I could solve this issue?

A:

The problem may be related to the syntax of your system username. In such case, go to your Hadoop directory and edit /etc/hadoop/hadoop-env.cmd
Near the end of the file you'll find:
set HADOOP_IDENT_STRING=%USERNAME%

change it to whatever name you want, but one NOT containing a space, eg.:
set HADOOP_IDENT_STRING=myuser

hope this will help

