tags:

views:

98

answers:

3

I am following Hadoop-the definitive Guide book.

confused on an example, (example 3-1)

there is a java file, (class URLCat)

I use javac to make it into URLCat.class then use jar to make it into a jar.

The book said

% hadoop URLCat hdfs://localhost/user/tom/quangle.txt

to run it... But I have tried a lot of different way..such as

% hadoop jar URLCat.jar .......

but didn't work

got error like :

Exception in thread "main" java.lang.ClassNotFoundException: hdfs://localhost/user/username/quangle/txt

why was that?

Thanks !

+1  A: 

The syntax of the command is a little bit different:

hadoop fs -cat hdfs:///user/tom/quangle.txt

Do you have hadoop home in your path? can you call hadoop without any parameters?

khmarbaise
re syntax, I have and I can. No problem.
Andy Leman
A: 

To make the hadoop URLCat command work you need to get the jar (URLCat.jar) to be in your class path. You can put it in lib/ dir of hadoop for that.

For the hadoop jar URLCat.jar to run you need to create a jar that will have Main class defined in it, otherwise it thinks that the next argument on the command line is the class name. What you can try is hadoop jar URLCat.jar URLCat hdfs://...

Dmytro Molkov
thank you. this helps
Andy Leman
A: 

It's quite simple:

[me@myhost ~]$ hadoop jar
RunJar jarFile [mainClass] args...

So, what you want is hadoop jar yourJar.jar your.class.with.Main [any args]

SquareCog