public static SamzaApplication fromConfig(Config config) {

    String appClassName = new ApplicationConfig(config).getAppClass();
    if (StringUtils.isNotBlank(appClassName)) {
      // app.class is configured
      try {
        Class<SamzaApplication> appClass = (Class<SamzaApplication>) Class.forName(appClassName);
        if (StreamApplication.class.isAssignableFrom(appClass) || TaskApplication.class.isAssignableFrom(appClass)) {
          return appClass.newInstance();
        }
      } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
        throw new ConfigException(String.format("Loading app.class %s failed. The user application has to implement "
            + "StreamApplication or TaskApplication.", appClassName), e);
      }
    }
    // no app.class defined. It has to be a legacy application with task.class configuration
    TaskConfig taskConfig = new TaskConfig(config);
    Optional<String> taskClassOption = taskConfig.getTaskClass();
    if (!taskClassOption.isPresent() || StringUtils.isBlank(taskClassOption.get())) {
      // no task.class defined either. This is wrong.
      throw new ConfigException("Legacy task applications must set a non-empty task.class in configuration.");
    }
    return new LegacyTaskApplication(taskClassOption.get());
  }
Creates the {@link SamzaApplication} object from the task or application class name specified in {@code config}

@param config the configuration of the application
@return the {@link SamzaApplication} object
samza-core/src/main/java/org/apache/samza/application/ApplicationUtil.java