Compile and Run a Job

DataPipeline jobs are plain old Java classes, they can be compiled and ran in exactly the same way. Add them to your IDE, ANT build, or command line as you would any other class.

If you're using the built-in expression language, remember to add the ANTLR jar (antlr-2.7.5.jar) to the classpath when running. If you're using Excel then add the JExcelApi jar(jxl-2.6.12.jar) and/or the POI jars:

  • dom4j-1.6.1.jar
  • poi-3.8-20120326.jar
  • poi-excelant-3.8-20120326.jar
  • poi-ooxml-3.8-20120326.jar
  • poi-ooxml-schemas-3.8-20120326.jar
  • poi-scratchpad-3.8-20120326.jar
  • stax-api-1.0.1.jar
  • xmlbeans-2.3.0.jar

Compiling

Given the following Data Pipeline job to convert a CSV file to fixed-width.

package com.northconcepts.datapipeline.examples.cookbook;

import java.io.File;

import com.northconcepts.datapipeline.core.DataReader;
import com.northconcepts.datapipeline.csv.CSVReader;
import com.northconcepts.datapipeline.fixedwidth.FixedWidthWriter;
import com.northconcepts.datapipeline.job.Job;

/**
 * Compiling and running a job is the same as for any other java class:
 * 
 * Compiling:   javac -classpath NorthConcepts-DataPipeline.jar CompileAndRunAJob.java
 *
 * Running:     java -classpath NorthConcepts-DataPipeline.jar;antlr-2.7.5.jar;poi-3.0-alpha2-20060616.jar;poi-contrib-3.0-alpha2-20060616.jar;poi-scratchpad-3.0-alpha2-20060616.jar;jxl-2.6.3.jar;itext-2.0.5.jar CompileAndRunAJob
 * 
 */
public class CompileAndRunAJob {

    public static void main(String[] args) {
        DataReader reader = new CSVReader(new File("example/data/input/credit-balance-01.csv"))
            .setFieldNamesInFirstRow(true);

        FixedWidthWriter writer = new FixedWidthWriter(new File("example/data/output/credit-balance-02.fw"));
        writer.addFields(8);
        writer.addFields(16);
        writer.addFields(16);
        writer.addFields(12);
        writer.addFields(14);
        writer.addFields(16);
        writer.addFields(7);

        Job.run(reader, writer);
    }

}

Compile it on the command line with javac.

javac -classpath NorthConcepts-DataPipeline-8.3.0.jar CompileAndRunAJob.java

Running

After compilation, run it by calling java.

java -classpath NorthConcepts-DataPipeline-8.3.0.jar CompileAndRunAJob

If the job uses Excel or the expression language, add their jars to the classpath.

java -classpath NorthConcepts-DataPipeline-8.3.0.jar;antlr-2.7.5.jar;dom4j-1.6.1.jar;poi-3.8-20120326.jar;poi-excelant-3.8-20120326.jar;poi-ooxml-3.8-20120326.jar;poi-ooxml-schemas-3.8-20120326.jar;poi-scratchpad-3.8-20120326.jar;stax-api-1.0.1.jar;xmlbeans-2.3.0.jar;jxl-2.6.12.jar CompileAndRunAJob
Mobile Analytics