You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by chaitanya krishna <ch...@gmail.com> on 2008/05/01 15:28:58 UTC

ClassNotFoundException while running jar file

Hi,

I wanted to run my own java code in hadoop. The following are the commands
that I executed and errors occurred.

mkdir temp

javac -Xlint -classpath hadoop-0.16.0-core.jar -d temp
GetFeatures.java                           (GetFeatures.java is the code)

jar -cvf temp.jar temp

bin/hadoop jar temp.jar GetFeatures input/input.txt out

ERROR:


Exception in thread "main" java.lang.ClassNotFoundException: GetFeatures
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        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:242)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:148)


can you interpret the possible reason for the error?

Thank you.

Re: ClassNotFoundException while running jar file

Posted by Jason Venner <ja...@attributor.com>.
You need to add your class or a class in your jar to the constructor for 
your JobConf object.

?????????????????????????????????????????????????????????
? JobConf(Class exampleClass)                           ?
?           Construct a map/reduce job configuration.   ?
?????????????????????????????????????????????????????????
? JobConf(Configuration conf, Class exampleClass)       ?
?           Construct a map/reduce job configuration.   ?
?????????????????????????????????????????????????????????


JobConf

public JobConf(Class exampleClass)

    Construct a map/reduce job configuration.
  
    Parameters:
        *exampleClass - a class whose containing jar is used as the 
job's jar.
   *


JobConf

public JobConf(Configuration conf,
               Class exampleClass)

    Construct a map/reduce job configuration.
  
    Parameters:
        conf - a Configuration whose settings will be inherited.
       * exampleClass - a class whose containing jar is used as the 
job's jar.*
  


chaitanya krishna wrote:
> Hi,
>
> I wanted to run my own java code in hadoop. The following are the commands
> that I executed and errors occurred.
>
> mkdir temp
>
> javac -Xlint -classpath hadoop-0.16.0-core.jar -d temp
> GetFeatures.java                           (GetFeatures.java is the code)
>
> jar -cvf temp.jar temp
>
> bin/hadoop jar temp.jar GetFeatures input/input.txt out
>
> ERROR:
>
>
> Exception in thread "main" java.lang.ClassNotFoundException: GetFeatures
>         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>         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:242)
>         at org.apache.hadoop.util.RunJar.main(RunJar.java:148)
>
>
> can you interpret the possible reason for the error?
>
> Thank you.
>
>   
-- 
Jason Venner
Attributor - Program the Web <http://www.attributor.com/>
Attributor is hiring Hadoop Wranglers and coding wizards, contact if 
interested