问题描述:

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.

[email protected]:/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.

[email protected]:/opt/hadoop#.

网友答案:

Hint:

Caused by: java.lang.ClassNotFoundException: .

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

网友答案:

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.

网友答案:

Try it removing "." in your command.

网友答案:

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

相关阅读:
Top