Skip to main content
Hitachi Vantara Lumada and Pentaho Documentation

Running Jobs

If you want to run a PDI job from Java code in a stand-alone application, take a look at this sample class, org.pentaho.di.sdk.samples.embedding.RunningJobs. It sets the parameters and executes the job in etl/parametrized_job.kjb. The job can be run from the .kjb file using runJobFromFileSystem() or from a repository using runJobFromRepository().
  1. Always make the first call to KettleEnvironment.init() whenever you are working with the PDI APIs..
  2. Prepare the job. The definition of a PDI job is represented by a JobMeta object. You can load this object from a .ktb file, a PDI repository, or you can generate it dynamically. To query the declared parameters of the job definition use listParameters(). To set the assigned values use setParameterValue().
  3. Execute the job. An executable Job object is derived from the JobMeta object that is passed in to the constructor. The Job object starts, and then executes in a separate thread. To wait for the job to complete, call waitUntilFinished().
  4. Evaluate the job outcome. After the Job completes, you can access the result using getResult(). The Result object can be queried for success using getResult(). This method returns true on success and false on failure. To get more information, retrieve the job log lines.