org.apache.hadoop.util

## Class FindClass

- java.lang.Object
- - org.apache.hadoop.conf.Configured
  - - org.apache.hadoop.util.FindClass

- All Implemented Interfaces:
    Configurable, Tool

      public final class FindClass
      extends Configured
      implements Tool

  This entry point exists for diagnosing classloader problems: is a class or resource present -and if so, where?

  Actions

  -     load

    : load a class but do not attempt to create it

  -     create

    : load and create a class, print its string value

  -     printresource

    : load a resource then print it to stdout

  -     resource

    : load a resource then print the URL of that resource
  It returns an error code if a class/resource cannot be loaded/found -and optionally a class may be requested as being loaded. The latter action will call the class's constructor -it must support an empty constructor); any side effects from the constructor or static initializers will take place. All error messages are printed to `System.out`; errors to `System.err`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `A_CREATE` create command: "create"
    `static String` | `A_LOAD` Load command: "load"
    `static String` | `A_PRINTRESOURCE` Command to locate and print a resource: "print"
    `static String` | `A_RESOURCE` Command to locate a resource: "locate"
    `protected static int` | `E_CREATE_FAILED` class creation failed 5
    `protected static int` | `E_GENERIC` generic error 1
    `protected static int` | `E_LOAD_FAILED` class load failed 4
    `protected static int` | `E_NOT_FOUND` class or resource not found 3
    `protected static int` | `E_USAGE` usage error -bad arguments or similar 2
    `static int` | `SUCCESS` Exit code when the operation succeeded: 0

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FindClass()` Empty constructor; passes a new Configuration object instance to its superclass's constructor
    `FindClass(Configuration conf)` Create a class with a specified configuration

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `main(String[] args)` Main entry point.
    `int` | `run(String[] args)` Run the class/resource find or load operation
    `static void` | `setOutputStreams(PrintStream out, PrintStream err)` Change the output streams to be something other than the System.out and System.err streams

    - ### Methods inherited from class org.apache.hadoop.conf.Configured

      `getConf, setConf`

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

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

    - ### Methods inherited from interface org.apache.hadoop.conf.Configurable

      `getConf, setConf`

- - ### Field Detail

    - #### A_CREATE

          public static final String A_CREATE

      create command: "create"
      See Also:
        Constant Field Values

    - #### A_LOAD

          public static final String A_LOAD

      Load command: "load"
      See Also:
        Constant Field Values

    - #### A_RESOURCE

          public static final String A_RESOURCE

      Command to locate a resource: "locate"
      See Also:
        Constant Field Values

    - #### A_PRINTRESOURCE

          public static final String A_PRINTRESOURCE

      Command to locate and print a resource: "print"
      See Also:
        Constant Field Values

    - #### SUCCESS

          public static final int SUCCESS

      Exit code when the operation succeeded: 0
      See Also:
        Constant Field Values

    - #### E_GENERIC

          protected static final int E_GENERIC

      generic error 1
      See Also:
        Constant Field Values

    - #### E_USAGE

          protected static final int E_USAGE

      usage error -bad arguments or similar 2
      See Also:
        Constant Field Values

    - #### E_NOT_FOUND

          protected static final int E_NOT_FOUND

      class or resource not found 3
      See Also:
        Constant Field Values

    - #### E_LOAD_FAILED

          protected static final int E_LOAD_FAILED

      class load failed 4
      See Also:
        Constant Field Values

    - #### E_CREATE_FAILED

          protected static final int E_CREATE_FAILED

      class creation failed 5
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### FindClass

          public FindClass()

      Empty constructor; passes a new Configuration object instance to its superclass's constructor

    - #### FindClass

          public FindClass(Configuration conf)

      Create a class with a specified configuration
      Parameters:
        `conf` - configuration

  - ### Method Detail

    - #### setOutputStreams

          public static void setOutputStreams(PrintStream out,
                                              PrintStream err)

      Change the output streams to be something other than the System.out and System.err streams
      Parameters:
        `out` - new stdout stream
        `err` - new stderr stream

    - #### run

          public int run(String[] args)
                  throws Exception

      Run the class/resource find or load operation
      Specified by:
        `run` in interface `Tool`
      Parameters:
        `args` - command specific arguments.
      Returns:
        the outcome
      Throws:
        `Exception` - if something went very wrong

    - #### main

          public static void main(String[] args)

      Main entry point. Runs the class via the `ToolRunner`, then exits with an appropriate exit code.
      Parameters:
        `args` - argument list

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.