How to Create a Task-Oriented Batch with the Java Batch API

import static java.lang.System.out;

import javax.batch.operations.JobOperator;
import javax.batch.runtime.BatchRuntime;

public final class BatchSample {

  public static void main(final String[] args) throws Exception {
    final JobOperator jobOperator = BatchRuntime.getJobOperator();

    out.println(jobOperator.start("samplejob", null));


import javax.batch.api.AbstractBatchlet;

public final class SampleBatchlet extends AbstractBatchlet {

  public String process() {
    return "COMPLETED";



<?xml version="1.0" encoding="UTF-8"?>
<job xmlns="" id="samplejob">
  <step id="step1">
    <batchlet ref="sampleBatchlet" />
    <next on="COMPLETED" to="step2" /> <!-- go the "step2" if the exit status is "COMPLETED" -->
  <step id="step2">


<?xml version="1.0" encoding="UTF-8"?>
<batch-artifacts xmlns="">
  <ref id="sampleBatchlet" class="SampleBatchlet" />

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s