RunJar (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.util, class: RunJar

Package org.apache.hadoop.util

# Class RunJar

java.lang.Object
org.apache.hadoop.util.RunJar

@Private @Unstable public class RunJar extends Object
Run a Hadoop job jar.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `HADOOP_CLASSPATH`
  Environment key for the (user-provided) hadoop classpath.
  `static final String`
  `HADOOP_CLIENT_CLASSLOADER_SYSTEM_CLASSES`
  Environment key for the system classes.
  `static final String`
  `HADOOP_CLIENT_SKIP_UNJAR`
  Environment key for disabling unjar in client code.
  `static final String`
  `HADOOP_USE_CLIENT_CLASSLOADER`
  Environment key for using the client classloader.
  `static final Pattern`
  `MATCH_ANY`
  Pattern that matches any string.
  `static final int`
  `SHUTDOWN_HOOK_PRIORITY`
  Priority of the RunJar shutdown hook.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RunJar()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `main(String[] args)`
  Run a Hadoop job jar.
  `void`
  `run(String[] args)`
  `void`
  `unJar(File jarFile, File toDir)`
  Unpack a jar file into a directory.
  `static void`
  `unJar(File jarFile, File toDir, Pattern unpackRegex)`
  Unpack matching files from a jar.
  `static void`
  `unJar(InputStream inputStream, File toDir, Pattern unpackRegex)`
  Unpack matching files from a jar.
  `static void`
  `unJarAndSave(InputStream inputStream, File toDir, String name, Pattern unpackRegex)`
  Deprecated.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### MATCH_ANY

    public static final Pattern MATCH_ANY
    Pattern that matches any string.

  - ### SHUTDOWN_HOOK_PRIORITY

    public static final int SHUTDOWN_HOOK_PRIORITY
    Priority of the RunJar shutdown hook.
    See Also:
      - Constant Field Values

  - ### HADOOP_USE_CLIENT_CLASSLOADER

    public static final String HADOOP_USE_CLIENT_CLASSLOADER
    Environment key for using the client classloader.
    See Also:
      - Constant Field Values

  - ### HADOOP_CLASSPATH

    public static final String HADOOP_CLASSPATH
    Environment key for the (user-provided) hadoop classpath.
    See Also:
      - Constant Field Values

  - ### HADOOP_CLIENT_CLASSLOADER_SYSTEM_CLASSES

    public static final String HADOOP_CLIENT_CLASSLOADER_SYSTEM_CLASSES
    Environment key for the system classes.
    See Also:
      - Constant Field Values

  - ### HADOOP_CLIENT_SKIP_UNJAR

    public static final String HADOOP_CLIENT_SKIP_UNJAR
    Environment key for disabling unjar in client code.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### RunJar

    public RunJar()

- ## Method Details

  - ### unJar

    public void unJar(File jarFile, File toDir) throws IOException
    Unpack a jar file into a directory. This version unpacks all files inside the jar regardless of filename.
    Parameters:
      `jarFile` - the .jar file to unpack
      `toDir` - the destination directory into which to unpack the jar
    Throws:
      `IOException` - if an I/O error has occurred or toDir cannot be created and does not already exist

  - ### unJar

    public static void unJar(InputStream inputStream, File toDir, Pattern unpackRegex) throws IOException
    Unpack matching files from a jar. Entries inside the jar that do not match the given pattern will be skipped.
    Parameters:
      `inputStream` - the jar stream to unpack
      `toDir` - the destination directory into which to unpack the jar
      `unpackRegex` - the pattern to match jar entries against
    Throws:
      `IOException` - if an I/O error has occurred or toDir cannot be created and does not already exist

  - ### unJarAndSave

    @Deprecated public static void unJarAndSave(InputStream inputStream, File toDir, String name, Pattern unpackRegex) throws IOException
    Deprecated.
    Unpack matching files from a jar. Entries inside the jar that do not match the given pattern will be skipped. Keep also a copy of the entire jar in the same directory for backward compatibility. TODO remove this feature in a new release and do only unJar
    Parameters:
      `inputStream` - the jar stream to unpack
      `toDir` - the destination directory into which to unpack the jar
      `unpackRegex` - the pattern to match jar entries against
      `name` - name.
    Throws:
      `IOException` - if an I/O error has occurred or toDir cannot be created and does not already exist

  - ### unJar

    public static void unJar(File jarFile, File toDir, Pattern unpackRegex) throws IOException
    Unpack matching files from a jar. Entries inside the jar that do not match the given pattern will be skipped.
    Parameters:
      `jarFile` - the .jar file to unpack
      `toDir` - the destination directory into which to unpack the jar
      `unpackRegex` - the pattern to match jar entries against
    Throws:
      `IOException` - if an I/O error has occurred or toDir cannot be created and does not already exist

  - ### main

    public static void main(String[] args) throws Throwable
    Run a Hadoop job jar. If the main class is not in the jar's manifest, then it must be provided on the command line.
    Parameters:
      `args` - args.
    Throws:
      `Throwable` - error.

  - ### run

    public void run(String[] args) throws Throwable
    Throws:
      `Throwable`