0

Mentioned below is the error that i am getting when trying to execute the java version of the WordCout. I was able to compile the same successfully but i am not able to figure out why it is cribbing now. i tried all combinations of the library path, thinking some dependency issue, but still stuck. Any help would be appreciated.

root@ubuntu:/opt/hadoop# java -cp lib/commons-cli-1.2.jar:hadoop-core-1.0.0.jar . /src/examples/org/apache/hadoop/examples/WordCount
Exception in thread "main" java.lang.NoClassDefFoundError: /
Caused by: java.lang.ClassNotFoundException: .
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: .. Program will exit.
root@ubuntu:/opt/hadoop#.

4 Answers 4

1

Hint:

Caused by: java.lang.ClassNotFoundException: .

java is trying to tell you that it cannot find the class named .

Sign up to request clarification or add additional context in comments.

Comments

1

When you run a Java program, you need to specify the actual class you are executing. What you have so far is this:

java -cp lib/commons-cli-1.2.jar:hadoop-core-1.0.0.jar .

All this is saying is that these two JARs should be in the CLASSPATH, and that you are trying to run some class called "." There is of course no such class named "." The . should be the name of the class you are trying to run, not a . . That class should have a main() method inside of it.

2 Comments

The file to be executed is mentioned, it got hidden because of the scroll bar :)
Several issues here. You have a space between the . and the rest of the path to the class (/src/examples/...) Remove the space. But also, you cannot specify a class to execute using a filesystem path. The class must be in your CLASSPATH. You could either add /src/examples to your CLASSPATH, or cd into /src/examples and run from there. Either way, the class should be specified as org.apache.hadoop.examples.WordCount.
0

Try it removing "." in your command.

Comments

0

Because the WordCount example is meant to launch a MapReduce job, it's intended to be run with the following:

bin/hadoop jar hadoop-*-examples.jar wordcount [-m <#maps>] [-r <#reducers>] <in-dir> <out-dir>

This will set up the classpath for you.

See http://wiki.apache.org/hadoop/WordCount

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.