Home > Mobile >  hadoop jar wordcount,jar wordcount exception
hadoop jar wordcount,jar wordcount exception

Time:10-22

Whenever I execute the command : hadoop jar wc.jar WordCount text.txt output It gives me this error

Exception in thread "main" java.lang.ClassNotFoundException: WordCount
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:316)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:236)

Even though everything seems to be fine

Can anyone help me out with this ??

CodePudding user response:

first of all you need to make sure you have a main method inside the WordCount class. You can also look at this answer right here: How to run a jar file in hadoop? As the answers suggest there's no problem when running the jar, but when creating the jar. So for example, you need to run:

JAVA_HOME/bin/jar cf WordCount.jar WordCount.class

and then run

hadoop jar WordCount.jar WordCount

Hope this helps.

  • Related