How do I run Hadoop using Java classes?… here is a solution to the problem.
How do I run Hadoop using Java classes?
I’m following the bookHadoop: the definitive Guide
I’m confused by example 3-1.
There is a Java source file, URLCat.java.
I compiled it into a URLCat.class using javac
and then wrapped
it into a jar using jar.
The book says to use
% hadoop URLCat hdfs://localhost/user/tom/quangle.txt
Run it. I tried a lot of different approaches, like
:
% hadoop jar URLCat.jar .......
But it didn’t work. I’m getting an error like this:
Exception in thread “main” java.lang.ClassNotFoundException: hdfs://localhost/user/username/quangle/txt
What is the reason for this and how can I deal with it correctly?
Solution
It’s simple:
[me@myhost ~]$ hadoop jar
RunJar jarFile [mainClass] args...
So, what you want is hadoop jar yourJar.jar your.class.with.Main [any args].