Class RunJar

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

@Private @Unstable public class RunJar extends Object
Run a Hadoop job jar.
  • 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:
    • HADOOP_USE_CLIENT_CLASSLOADER

      public static final String HADOOP_USE_CLIENT_CLASSLOADER
      Environment key for using the client classloader.
      See Also:
    • HADOOP_CLASSPATH

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

      public static final String HADOOP_CLIENT_CLASSLOADER_SYSTEM_CLASSES
      Environment key for the system classes.
      See Also:
    • HADOOP_CLIENT_SKIP_UNJAR

      public static final String HADOOP_CLIENT_SKIP_UNJAR
      Environment key for disabling unjar in client code.
      See Also:
  • 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