Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7685041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:09:54+00:00 2026-05-31T19:09:54+00:00

I have been trying to call a mapreduce job from a simple java program

  • 0

I have been trying to call a mapreduce job from a simple java program in the same package.. I tried to refer the mapreduce jar file in my java program and call it using the runJar(String args[]) method by also passing the input and output paths for the mapreduce job.. But the program dint work..


How do I run such a program where I just use pass input, output and jar path to its main method?? Is it possible to run a mapreduce job (jar) through it?? I want to do this because I want to run several mapreduce jobs one after another where my java program vl call each such job by referring its jar file.. If this gets possible, I might as well just use a simple servlet to do such calling and refer its output files for the graph purpose..


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author root
 */
import org.apache.hadoop.util.RunJar;
import java.util.*;

public class callOther {

    public static void main(String args[])throws Throwable
    {

        ArrayList arg=new ArrayList();

        String output="/root/Desktp/output";

        arg.add("/root/NetBeansProjects/wordTool/dist/wordTool.jar");

        arg.add("/root/Desktop/input");
        arg.add(output);

        RunJar.main((String[])arg.toArray(new String[0]));

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:09:55+00:00Added an answer on May 31, 2026 at 7:09 pm

    Oh please don’t do it with runJar, the Java API is very good.

    See how you can start a job from normal code:

    // create a configuration
    Configuration conf = new Configuration();
    // create a new job based on the configuration
    Job job = new Job(conf);
    // here you have to put your mapper class
    job.setMapperClass(Mapper.class);
    // here you have to put your reducer class
    job.setReducerClass(Reducer.class);
    // here you have to set the jar which is containing your 
    // map/reduce class, so you can use the mapper class
    job.setJarByClass(Mapper.class);
    // key/value of your reducer output
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Text.class);
    // this is setting the format of your input, can be TextInputFormat
    job.setInputFormatClass(SequenceFileInputFormat.class);
    // same with output
    job.setOutputFormatClass(TextOutputFormat.class);
    // here you can set the path of your input
    SequenceFileInputFormat.addInputPath(job, new Path("files/toMap/"));
    // this deletes possible output paths to prevent job failures
    FileSystem fs = FileSystem.get(conf);
    Path out = new Path("files/out/processed/");
    fs.delete(out, true);
    // finally set the empty out path
    TextOutputFormat.setOutputPath(job, out);
    
    // this waits until the job completes and prints debug out to STDOUT or whatever
    // has been configured in your log4j properties.
    job.waitForCompletion(true);
    

    If you are using an external cluster, you have to put the following infos to your configuration via:

    // this should be like defined in your mapred-site.xml
    conf.set("mapred.job.tracker", "jobtracker.com:50001"); 
    // like defined in hdfs-site.xml
    conf.set("fs.default.name", "hdfs://namenode.com:9000");
    

    This should be no problem when the hadoop-core.jar is in your application containers classpath.
    But I think you should put some kind of progress indicator to your web page, because it may take minutes to hours to complete a hadoop job 😉

    For YARN (> Hadoop 2)

    For YARN, the following configurations need to be set.

    // this should be like defined in your yarn-site.xml
    conf.set("yarn.resourcemanager.address", "yarn-manager.com:50001"); 
    
    // framework is now "yarn", should be defined like this in mapred-site.xm
    conf.set("mapreduce.framework.name", "yarn");
    
    // like defined in hdfs-site.xml
    conf.set("fs.default.name", "hdfs://namenode.com:9000");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to call filter css method from jquery for IE, but
I have been trying to call filter css method from jquery for IE, but
I have been trying to call some functions from a library provided by a
I have been trying to return an ARABIC string from a JNI call. The
I have been trying to call the NewPixelRegionIterator function in ImageMagick's library from C#
I have been trying to call a C function that has the following signature
I have been trying to figure out how to implement a simple xml rpc
I have been trying to get a simple spider to run with scrapy, but
I have been trying to use JSON to store settings for a program. I
I have been trying to write a simple mention grabber to get started with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.