Hi,
I'm not sure if my original reply was any use. But here's some background on running jar's on hadoop that may help.

Basically, the jar command runs the JarUtil class. This attempts to unpack the jar and first looks in its Manifest file. If there is a main class specified it will attempt to run it. If not it will look for the argument following the word jar on the command line (in your case Wordcount) and will attempt to run that class.

As an aside, in the *examples*.jar the mainclass is specified in the Manifest and is a Driver program. I'd recommend having a look at the source for this. This driver takes the next argument on the command line and matches it to a string associated with a class. It then runs that class. This is why bin/hadoop jar *examples*.jar pi 10 10 works when the class is actually called ?????


So, with your own WordCount.jar, you are using the first method described. However, the exception you get is saying you have the wrong class name. I get this exception when I have the correct class name, but without the correct folder structure before it, corresponding to the package it is in. If the class is not there at all, you don't get the "wrong name" part of the exception.

I think your hadoop is probably set up correctly, there's just some problemt, either with the file structure inside your jar or with what you type on the command line.

Actually, looking at how you jarred it, I think you should do the following:
jar -cvf WordCount.jar package/structure/*.class, where package/structure is the folder structure corresponding to the package your class is in and you are in the folder that contains the directory package. Then to run:
bin/hadoop jar WordCount.jar package/structure/WorCount dir dir
If its not in a package, then I don't know what's going on!

Hope some of this helped.

Ollie


 Quoting C G <[EMAIL PROTECTED]>:

I've deployed hadoop-0.13.0 and successfully run some examples. Now I am trying to compile and run the examples prior to starting to develop my own code. I've managed to do little more than get a nice spew of error messages. This is no doubt due to my own ignorance and too much Python programming, but can anybody tell me how to compile the examples (WordCount.java for example) and run them?

I apologize for the basic question, which I am sure is classpath-magic related. Any assistance most appreciated. I promise to be helpful to other newbs like myself going forward.

I've tried a bunch of stuff, but it all comes down to various "can't find class X' errors. This is representative of as far as I've gotten:
  % java -version
  java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode, sharing
  % cd ${HADOOP_HOME}/hadoop-0.13.0/src/examples/org/apache/hadoop/examples
% javac -classpath ${HADOOP_HOME}/hadoop-0.13.0/hadoop-0.13.0-core.jar WordCount.java
  % jar -cvf WordCount.jar *.class
  % cp *.jar ${HADOOP_HOME/hadoop-0.13.0/
  % cd ${HADOOP_HOME/hadoop-0.13.0/
% bin/hadoop jar WordCount.jar WordCount input_files/text.txt output_files/results2.txt Exception in thread "main" java.lang.NoClassDefFoundError: WordCount (wrong name: org/apache/hadoop/examples/WordCount)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:148)



---------------------------------
Luggage? GPS? Comic books?
Check out fitting  gifts for grads at Yahoo! Search.



Reply via email to