Month: January 2009

Using Eclipse Jobs API

Eclipse platform offers great API for managing long running operations in the background. Besides the API for starting, stopping and monitoring progress of the Job – there is also standard UI for managing all those operations. I’m going to present sample usage of Jobs API in you own plug-in/application.

Creating and scheduling Job may look like this:

 TrainJob job = new TrainJob(TRAIN_JOB_NAME + file.getName(), classifier);
 job.schedule(); // start as soon as possible

Sample of custom Job:


import static org.eclipse.core.runtime.Status.OK_STATUS;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;

 * Class for execution of training of a classifier
 * @since 1.0
public class TrainJob extends Job {
 private AbstractClassifier classifier;

  * Public constructor TrainJob
  * @param name Train job name
  * @param classifier Classifier to be trained
 public TrainJob(String name, AbstractClassifier classifier) {
 	this.classifier = classifier;

 protected IStatus run(IProgressMonitor monitor) {
 	// Long running operation - in this case classifier training
       // ...
       return OK_STATUS;


Standard GUI for presenting Job progress:

Jobs API View