java 无法找到或加载主类 com.sun.tools.javac.Main hadoop mapreduce
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29260900/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not find or load main class com.sun.tools.javac.Main hadoop mapreduce
提问by Liondancer
I am trying to learn MapReduce but I am a little lost right now.
我正在尝试学习 MapReduce,但我现在有点迷茫。
Particularly this set of instructions:
特别是这组指令:
Compile WordCount.java and create a jar:
$ bin/hadoop com.sun.tools.javac.Main WordCount.java
When I type in hadoop
in my terminal I am able to see the "Help" made which provides arguments so I believe I have hadoop installed.
当我在hadoop
终端中输入时,我能够看到提供参数的“帮助”,所以我相信我已经安装了 hadoop。
When I type in the command:
当我输入命令时:
Compile WordCount.java and create a jar:
编译 WordCount.java 并创建一个 jar:
hadoop com.sun.tools.javac.Main WordCount.java
hadoop com.sun.tools.javac.Main WordCount.java
I get the error:
我收到错误:
Error: Could not find or load main class com.sun.tools.javac.Main
Error: Could not find or load main class com.sun.tools.javac.Main
I know I have Java installed and working on my computer because I've used it before to create other programs.
我知道我已经安装了 Java 并在我的计算机上工作,因为我以前用它来创建其他程序。
This command outputs:
此命令输出:
$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home
Maybe I am missing a set of Java tools? Not sure
也许我缺少一组 Java 工具?不确定
回答by Nguyen Sy Thanh Son
I got same error.
我有同样的错误。
And i solved it by add HADOOP_CLASSPATH environment parameter:
我通过添加 HADOOP_CLASSPATH 环境参数解决了它:
export HADOOP_CLASSPATH=/usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar
Please make sure that you installed OpenJDK7. I am using Ubuntu 14.04:
请确保您安装了 OpenJDK7。我正在使用 Ubuntu 14.04:
sudo apt-get install openjdk-7-jdk
回答by Mr. Z
The bin/hadoop com.sun.tools.javac.Main WordCount.java
is finaly running as
java com.sun.tools.javac.Main WordCount.java
.
最终bin/hadoop com.sun.tools.javac.Main WordCount.java
以
java com.sun.tools.javac.Main WordCount.java
.
If your classpath/javahome is right, then try to type java ...
yourself, and check the name com.sun.tools...
by using TAB key. Maybe the name is not a proper one. (egg. you are using java from Oracle rather than SUN)
如果您的类路径/javahome 是正确的,则尝试java ...
自己键入,并com.sun.tools...
使用 TAB 键检查名称。也许这个名字不是一个合适的名字。(例如,您使用的是来自 Oracle 而不是 SUN 的 java)
Another suggestion is modifying the $HADOOP_HOME/etc/hadoop/hadoop-env.sh
. Add the tools.jar
into HADOOP_CLASSPATH
.
另一个建议是修改$HADOOP_HOME/etc/hadoop/hadoop-env.sh
. 添加tools.jar
到HADOOP_CLASSPATH
.
回答by Anna Chen
You may not install jdk. Check your /lib/tools.jar in your java folder.
If not, #sudo apt-get install default-jdkand the error disappears.
你可能没有安装jdk。检查您的 java 文件夹中的 /lib/tools.jar。
如果没有,#sudo apt-get install default-jdk错误就会消失。