简体   繁体   English

Java:尝试编译Hadoop程序时找不到com.sun.tools.javac.Main

[英]Java: com.sun.tools.javac.Main not found when trying to compile Hadoop program

When I try to compile my program in Hadoop with this command 当我尝试使用此命令在Hadoop中编译我的程序时

bin/hadoop com.sun.tools.javac.Main WordCounter.java

from Hadoop folder, it says 它说,来自Hadoop文件夹

Error: Could not find or load main class com.sun.tools.javac.Main

I looked in similar threads where people suggested to check if JAVA_HOME is properly stated. 我查看了类似的线程,人们建议检查JAVA_HOME是否正确陈述。 So in etc/hadoop/hadoop-env.sh I added this line 所以在etc/hadoop/hadoop-env.sh我添加了这一行

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

then checked if tools.pack is properly unpacked in /usr/lib/jvm/java-7-openjdk-amd64/lib and it was. 然后检查tools.pack是否在/usr/lib/jvm/java-7-openjdk-amd64/lib正确解压缩。 Then I tried javac -version which gave 然后我尝试了javac -version

javac 1.7.0_65

I tried to reinstall Java but it didn't solve the problem. 我试图重新安装Java,但它没有解决问题。

尝试设置HADOOP_CLASSPATH环境变量

export HADOOP_CLASSPATH=$JAVA_HOME/lib/tools.jar

The error means you don't use a JDK to start Hadoop. 该错误意味着您不使用JDK来启动Hadoop。 The main difference between the JRE (pure runtime) and the JDK is the Java compiler javac . JRE(纯运行时)和JDK之间的主要区别是Java编译器javac To see if you have a Java compiler, you need to check two places: There should be a javac in the $JAVA_HOME/bin folder plus there must be a file $JAVA_HOME/lib/tools.jar . 要查看是否有Java编译器,需要检查两个位置: $JAVA_HOME/bin文件夹中应该有一个javac ,并且必须有一个文件$JAVA_HOME/lib/tools.jar

In your case, the first one (the binary to start the compiler) can be missing but you absolutely need the tools.jar . 在您的情况下,第一个(启动编译器的二进制文件)可能会丢失,但您绝对需要tools.jar

You say that you have a tools.pack but I haven't heard about this one before. 你说你有一个tools.pack但我以前没有听说过这个。 Use your package manager to search for openjdk and then look for a package in the result list which says jdk . 使用包管理器搜索openjdk ,然后在结果列表中查找包含jdk On my system, that would be openjdk-7-jdk . 在我的系统上,那将是openjdk-7-jdk Install this package and the error should go away. 安装此软件包,错误应该消失。

I had to downgrade Hadoop to 2.9.2 and it's working. 我不得不将Hadoop降级到2.9.2并且它正在运行。

I also had these in my environment: 我在我的环境中也有这些:

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
export PATH=${JAVA_HOME}/bin:${PATH}
export HADOOP_CLASSPATH=${JAVA_HOME}/lib/tools.jar

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 字数统计 hadoop 程序:错误:无法找到或加载主类 com.sun.tools.javac.Main - Word Count hadoop program: Error: Could not find or load main class com.sun.tools.javac.Main com.sun.tools.javac.Main不在类路径中 - com.sun.tools.javac.Main is not on the classpath Hadoop“无法找到或加载主类com.sun.tools.javac.Main” - Hadoop “Could not find or load main class com.sun.tools.javac.Main” 无法找到或加载主类com.sun.tools.javac.Main hadoop mapreduce - Could not find or load main class com.sun.tools.javac.Main hadoop mapreduce Hadoop 编译错误:无法找到或加载主类 com.sun.tools.javac.Main - Hadoop Compilation Error: Could not find or load main class com.sun.tools.javac.Main Unable to find a javac compiler com.sun.tools.javac.Main is not on the classpath 错误 - Unable to find a javac compiler com.sun.tools.javac.Main is not on the classpath error 编译器错误 - “错误:无法找到或加载主类 com.sun.tools.javac.Main” - Compiler Error - 'Error: Could not find or load main class com.sun.tools.javac.Main' 在Ubuntu上安装Jetty,获取com.sun.tools.javac.Main不在类路径上 - Installing Jetty on Ubuntu, getting com.sun.tools.javac.Main is not on the classpath Eclipse/Ant 构建失败 - com.sun.tools.javac.Main 不在类路径上 - Eclipse/Ant build failure - com.sun.tools.javac.Main is not on the classpath java.lang.NoClassDefFoundError:com / sun / tools / javac / Main - java.lang.NoClassDefFoundError: com/sun/tools/javac/Main
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM