Could not find or load main class com.sun.tools.javac.Main hadoop mapreduce
Asked Answered
N

3

11

I am trying to learn MapReduce but I am a little lost right now.

http://hadoop.apache.org/docs/r2.6.0/hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduceTutorial.html#Usage

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.

When I type in the command:

Compile WordCount.java and create a jar:

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

I know I have Java installed and working on my computer because I've used it before to create other programs.

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

Neiman answered 25/3, 2015 at 16:13 Comment(3)
is your Wordcount.java is in bin/hadoop directory.Alper
are you able run it.Alper
Possible duplicate of Java: com.sun.tools.javac.Main not found when trying to compile Hadoop programCandycecandystriped
G
20

I got same error.

And i solved it by add HADOOP_CLASSPATH environment parameter:

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:

sudo apt-get install openjdk-7-jdk
Glucose answered 27/5, 2015 at 4:39 Comment(1)
As it is originally stated in documentation (tutorial): hadoop.apache.org/docs/stable/hadoop-mapreduce-client/…Pig
T
3

The bin/hadoop com.sun.tools.javac.Main WordCount.java is finaly running as 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)

Another suggestion is modifying the $HADOOP_HOME/etc/hadoop/hadoop-env.sh. Add the tools.jar into HADOOP_CLASSPATH.

Teryl answered 15/4, 2016 at 6:29 Comment(0)
M
2

You may not install jdk. Check your /lib/tools.jar in your java folder.
If not, #sudo apt-get install default-jdk and the error disappears.

Mcnully answered 1/10, 2015 at 4:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.