I followed the jar construction step mentioned in the Usage section (link
below) and also the step mentioned to run specific classes in the jar.

http://hadoop.apache.org/common/docs/r0.20.1/mapred_tutorial.html#Usage

I replaced the classes folder with bin because thats where Eclipse puts in
the compiled classes. Since I didn't provide any manifest file, I give the
classname along with jar to hadoop.

jar -cvf Sample.jar -C bin/ .

Doing this way works for me. You can try the same.

Raghava.

On Fri, Jun 18, 2010 at 3:39 AM, Sugandha Naolekar
<[email protected]>wrote:

> The steps mentioned in d above mail of mine r d ones dat I follwed.!
> If some one could repeat d same, the problem can b better understood.
>
> How to run a Hadoop jar file Through Runjar API....???
>
> See simply, a built jar file can b passed as a parameter and where to be
> extracted in the unjar static methos of RUnJar class. But, I want to invoke
> HDFS and not Local FS. For that purpose, I am tryin to run the jar through
> prompt as bin.hadoop jar jar_file_name. But, that doesn't seem to be
> working. Can I get a way out??
> Regards!
> Sugandha
>
>
> On Fri, Jun 18, 2010 at 12:26 PM, Chandraprakash Bhagtani <
> [email protected]> wrote:
>
> > the problem may be in your jar creation or the path where you are copying
> > the jar may be different from the jar command you are running.
> >
> > try building jar from eclipse itself and make sure you are giving correct
> > path of the jar file to hadoop command.
> >
> > On Fri, Jun 18, 2010 at 11:01 AM, Sugandha Naolekar
> > <[email protected]>wrote:
> >
> > > Now the jar is getting built but, when i try 2 run it, it diplays
> > > following.....
> > >
> > > >bin/hadoop jar Sample.jar
> > > RunJar jarFile [mainClass] args...
> > > PLease suggest something...if possible, d procedures I have followed
> can
> > be
> > > tried by someone..!!
> > >
> > > Regards!
> > > Sugandha
> > >
> > >
> > > On Fri, Jun 18, 2010 at 8:13 AM, Sugandha Naolekar
> > > <[email protected]>wrote:
> > >
> > > > Following things I did::
> > > >
> > > > 1) I went into the hadoop diectory- the path is
> > > > /home/hadoop/Softwares/hadoop0.19.0
> > > > 2) Then I made a folder named Try under the above path. I added all
> the
> > > > jars under lib directory and the bin folder in which, my code lies.
> > This
> > > bin
> > > > folder got created under the eclipse's wrkspace.
> > > > 3) Since I just need to try the execution of sample code thro'
> hadoop's
> > > > prompt, I wrote a code as::
> > > >
> > > > package h.pkg;
> > > >
> > > > public class PC {
> > > >     public static void main(String[] args) {
> > > > System.out.println("A trial code thro' hadoop propmt..!!");    }
> > > > }
> > > > 4) Thus, this entire package under bin of eclipse's wrkspace was
> placed
> > > in
> > > > the Try folder.
> > > > 5) Then, there was MANIFEST.MF consisting of following content::
> > > > Manifest-Version: 1.0
> > > > Created-By: 1.6.0_14 (Sun Microsystems Inc.)
> > > > Main-Class: h.pkg.PC
> > > > 6) After the above, I simple built a jar as follows::
> > > >
> > > > /home/hadoop/Softwares/hadoop>  jar cfmv Sample.jar MANIFEST.MF -C
> Try/
> > .
> > > > (the propmt)
> > > > 7) Thus, the jar was built, as I could see all the contents getting
> > added
> > > > into it...
> > > > 8) Then I simply did try 2 run it as::/home/hadoop/Softwares/hadoop>
> > > > bin/hadoop jar Sample.jar
> > > > 9) It gave me following errors::
> > > >
> > > > ad...@hadoop:~/Softwares/hadoop-0.19.0$ bin/hadoop jar H.jar
> > > > java.lang.ClassNotFoundException: h.pkg.PC
> > > >     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:307)
> > > >     at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
> > > >     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
> > > >     at java.lang.Class.forName0(Native Method)
> > > >     at java.lang.Class.forName(Class.java:247)
> > > >     at org.apache.hadoop.util.RunJar.main(RunJar.java:158)
> > > >     at org.apache.hadoop.mapred.JobShell.run(JobShell.java:54)
> > > >     at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
> > > >     at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
> > > >     at org.apache.hadoop.mapred.JobShell.main(JobShell.java:68)
> > > >
> > > > 10) Please suggest for the above!
> > > >
> > > >
> > > >
> > > > Regards!
> > > > Sugandha
> > > >
> > > >
> > > >
> > > > On Fri, Jun 18, 2010 at 7:32 AM, Raghava Mutharaju <
> > > > [email protected]> wrote:
> > > >
> > > >> did you use the following?
> > > >>
> > > >> bin/hadoop jar <JarFilename> <fullyQualifiedClassName>
> > > >>
> > > >> Raghava.
> > > >>
> > > >> On Thu, Jun 17, 2010 at 9:21 PM, Sugandha Naolekar
> > > >> <[email protected]>wrote:
> > > >>
> > > >> > I need to execute a code through the propmt of hadoop,i.e;
> > > bin/hadoop>.
> > > >> > So, I built the jar of it using jar cfmv Jarfile_name
> > > Manifest_filename
> > > >> -C
> > > >> > directory_name/ .(in which d jars,and class files are added).
> > > >> > After that, I simply execute the code thro' bin/hadoop
> Jarfilename.
> > > >> >
> > > >> > But, I get an error of Class Not found exception.
> > > >> >
> > > >> > Can I please get the entire procedure of building a jar and then
> > > running
> > > >> it
> > > >> > through prompt??
> > > >> >
> > > >> >
> > > >> > Regards!
> > > >> > Sugandha
> > > >> >
> > > >>
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > Thanks & Regards,
> > Chandra Prakash Bhagtani,
> > Nokia India Pvt. Ltd.
> >
>

Reply via email to