我如何运行Hadoop和Java类一起运行? [英] How can I run Hadoop run with a Java class?

查看:191
本文介绍了我如何运行Hadoop和Java类一起运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 Hadoop:权威指南一书。



我对示例3-1感到困惑。

有一个Java源文件URLCat.java。
我使用 javac 将其编译到URLCat.class中,然后使用 jar 将其包装到jar中。



本书说使用

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

来运行它。我尝试了很多不同的方法,比如

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

但没有用。我有这样的错误:


线程main中的异常java.lang.ClassNotFoundException:hdfs:// localhost / user / username / quangle / txt


这是什么原因,以及如何正确使用它?

解决方案

>语法的命令有点不同:

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

你有回家的路程吗?你可以不带任何参数调用hadoop?


I am following the book Hadoop: the definitive Guide.

I am confused on example 3-1.

There is a Java source file, URLCat.java. I use javac to compile it into URLCat.class, then use jar to wrap it into a jar.

The book said to use

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

to run it. I have tried a lot of different ways, such as

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

but didn't work. I got errors like this:

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

What is the reason for this, and how do I do it right?

解决方案

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?

这篇关于我如何运行Hadoop和Java类一起运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆