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 Details

  • Constructor Details

    • 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 Details

    • setOutputStreams

      @VisibleForTesting 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