Support Questions

Find answers, ask questions, and share your expertise

Could not find or load main class dfsadmin

avatar
Super Collaborator

Was trying to run 'hdfs dfsadmin -safemode enter'. It was throwing message saying 'could not find or load main class dfsadmin'.

Can someone help me understanding under which circumstances would we get this error and what is the work around to make it work.

Thank you in advance

1 ACCEPTED SOLUTION

avatar
Master Mentor

@Viswa

One of the reason can be special characters (Non printable) in the command Because the error that you are getting can occur if "hdfs" command is not able to locate the class related to the argument.

Example::

# hdfs dsfadmin -safemode enter
Error: Could not find or load main class dsfadmin

- In this example i intentionally made a spelling mistake in 'dfsadmin" argument to explain. In your case it might be due to some special hidden chars.

.

So you should try check that you are not copying and pasting the command in the terminal... instead try to manually type the command.

Also check the output of the following to see if you are getting the correct command output:

#  hdfs --help | grep dfsadmin
  dfsadmin             run a DFS admin client

View solution in original post

2 REPLIES 2

avatar
Master Mentor

@Viswa

One of the reason can be special characters (Non printable) in the command Because the error that you are getting can occur if "hdfs" command is not able to locate the class related to the argument.

Example::

# hdfs dsfadmin -safemode enter
Error: Could not find or load main class dsfadmin

- In this example i intentionally made a spelling mistake in 'dfsadmin" argument to explain. In your case it might be due to some special hidden chars.

.

So you should try check that you are not copying and pasting the command in the terminal... instead try to manually type the command.

Also check the output of the following to see if you are getting the correct command output:

#  hdfs --help | grep dfsadmin
  dfsadmin             run a DFS admin client

avatar
Super Collaborator

tried the same command again later, it worked. haven't changed anything.

Thank you Jay SenSharma