0

I am new to Hadoop and am following the book Hadoop: The Definitive Guide. I have installed Hadoop on my mac, which seems to have worked fine. I have set up a basic file system in HDFS (/user/nick). But I can't get the 'hadoop' command to execute a class file as required in Chapter 3 (p 56). It doesn't seem to be the file because the 'hadoop'command won't open even a simple file where where java command works fine. This is what my terminal looks like for the simple file:

Unix ~/Desktop $ java TestJava

Hello Test World

Unix ~/Desktop $ hadoop TestJava

Error: Could not find or load main class TestJava

All the other hadoop commands I have tried work fine (hadoop -ls, hadoop -copyFromLocal, hadoop -mkdir etc), but hadoop CLASSNAME doesn't work when the class file is saved on the desktop. I always get Error: Could not find or load main class TestJava.

Am I saving the class file in the wrong place or have I set up hadoop wrong?

I am new to this and have searched for an answer but couldn't find a solution. Any help would be much appreciated.

Thanks,

Nick

1 Answer 1

3

You are assuming hadoop command to be equivalent to java command which is not the case. Basically you run Mapred with Hadoop command where you write Mapper, Reducer(optional), Driver code and then you create a jar file will all these files and issue command like:

hadoop jar myjar.jar DriverClass inputInHdfs OutputPathInHdfs

You could refer tutorial here

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for helping. I will have a go at the tutorial.
If this helped then please accept this answer so it gets closed off.
Thanks. This also helped -stackoverflow.com/questions/3606679/…
I needed to type this first export HADOOP_CLASSPATH=/Users/Nick/Desktop

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.