0

I am facing this issue while trying to run the Mapreduce Wordcount example:

Exception in thread "main" java.lang.ClassNotFoundException: /usr/local/hadoop/input
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:214)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136)

I read that this is because when a jar file is created I didn't choose the main file.

This is the command I used to create the jar file for your reference:

javac -classpath /usr/local/hadoop/etc/hadoop:/usr/local/hadoop/share/hadoop/common/lib/* :/usr/local/hadoop/share/hadoop/common/* :/usr/local/hadoop/share/hadoop/hdfs:/usr/local/hadoop/share/hadoop/hdfs/lib/* :/usr/local/hadoop/share/hadoop/hdfs/* :/usr/local/hadoop/share/hadoop/yarn/lib/* :/usr/local/hadoop/share/hadoop/yarn/* :/usr/local/hadoop/share/hadoop/mapreduce/lib/* :/usr/local/hadoop/share/hadoop/mapreduce/* :/contrib/capacity-scheduler/*.jar -d wordcount_classes WordCount.java

Basically, I think I want the command line equivalent of this question : question.

Community
  • 1
  • 1
Flame of udun
  • 2,136
  • 7
  • 35
  • 79

1 Answers1

2

try using manifest file for main class and use below steps to create a jar

Creating a jar File in Command Prompt

Start Command Prompt.
Navigate to the folder that holds your class files:

C:\>cd \mywork

Set path to include JDK’s bin.  For example:

C:\mywork> path c:\Program Files\Java\jdk1.7.0_25\bin;%path%

Compile your class(es):

C:\mywork> javac *.java

Create a manifest file and your jar file:

C:\mywork> echo Main-Class: Craps >manifest.txt

C:\mywork> jar cvfm Craps.jar manifest.txt *.class

or

C:\mywork> jar cvfe Craps.jar Craps *.class

Test your jar:

C:\mywork> Craps.jar

or

C:\mywork> java -jar Craps.jar
shripad vade
  • 199
  • 7