This topic describes how to run a JAR command on the MaxCompute client to submit a MapReduce job.

The MaxCompute client provides a JAR command to submit MapReduce jobs. Example:
jar -conf \home\admin\myconf -resources a.txt,example.jar -classpath ..\lib\example.jar:.\other_lib.jar -D java.library.path=.\native;


        -conf <configuration_file>         Specify an application configuration file
        -resources <resource_name_list>    file\table resources used in mapper or reducer, seperate by comma
        -classpath <local_file_list>       classpaths used to run mainClass
        -D <name>=<value>                  Property value pair, which will be used to run mainClass
        -l                                 Run job in local mode


<GENERIC_OPTIONS> includes the following optional parameters:
  • -conf <configuration file>: specifies the JobConf configuration file. This file contains the settings of JobConf in SDK.
    The following code shows the template of a JobConf file:

    In this example, a variable named import.filename whose value is resource.txt is specified in the JobConf configuration file.

    You can call the JobConf interface in MapReduce to obtain the value of this variable. You can also call the JobConf interface in SDK to obtain the variable value. For more information, see Resource samples.

    add jar data\mapreduce-examples.jar;
        jar -resources mapreduce-examples.jar -classpath data\mapreduce-examples.jar
   wc_in wc_out;
        add file data\src.txt;
        add jar data\mapreduce-examples.jar;
        jar -resources src.txt,mapreduce-examples.jar -classpath data\mapreduce-examples.jar
   wc_in wc_out;
        add file data\a.txt;
        add table wc_in as test_table;
        add jar data\work.jar;
        jar -conf odps-mapred.xml -resources a.txt,test_table,work.jar
            -classpath data\work.jar:otherlib.jar
            -D import.filename=resource.txt args;
  • -resources <resource_name_list>: specifies the resources that are used to run a MapReduce job. In most cases, you must specify the names of the resources that are used by the map or reduce function in the resource_name_list.
    • If the map or reduce function reads other MaxCompute resources, you must also add the names of these resources to resource_name_list.
    • Multiple resources must be separated by commas (,). If you use cross-project resources, add PROJECT/resources/ before resource_name_list. Example: -resources otherproject/resources/resfile.
    • For more information about how to use the map or reduce function to read resources, see Resource samples.
  • -classpath <local_file_list>: specifies the classpath that is used to run a MapReduce job in local mode. This parameter specifies the local paths. The paths include both the relative and absolute paths of the JAR package where the main function is located.

    Package names are separated by default file delimiters. In most cases, the Windows operating system uses semicolons (;) as the default file delimiter, and Linux uses commas (,). If you run a MapReduce job on a cloud server, separate package names with commas (,).

    Note You may prefer to compile the main function in the same package as the map or reduce function. For more information, see WordCount samples. In this case, when you execute the sample program, mapreduce-examples.jar is included in both the -resources and -classpath options. However, the -resources option references the map or reduce function for distributed execution. The -classpath option references the main function for local execution. The specified JAR package must also be saved in a local directory.
  • -D <prop_name>=<prop_value>: specifies the Java property of <mainClass> for local execution. You can specify multiple properties.
  • -l: specifies that the MapReduce job is executed in local mode. This option is used for program debugging.