title: Running Spring Batch jobs from the command line
body: <p>I don't know how to call a Job defined in Spring Batch using <code>CommandLineJobRunner</code>, documentation details are not enough for me.</p>
  
  <p>I've followed the <a href="http://spring.io/guides/gs/batch-processing/" rel="noreferrer">Spring Batch official guide</a> to write Jobs in Spring Batch using Java annotations e.g. <code>@EnableBatchProcessing</code> because I wanted to avoid XML configuration files for the description of the job, the steps, etc.</p>
  
  <p>So far I have:</p>
  
  <ul>
  <li>a configuration class (<code>com.package.bla.bla.ClassContainingTheBatchConfiguration</code> see below) where I've put all the stuff defining <code>ItemReader</code>, <code>ItemProcessor</code>, <code>ItemWriter</code>, <code>Job</code>, and <code>Step</code> (with <code>return jobs.get("nameOfTheJob")</code> see below) using a <code>@Bean</code> annotaion.</li>
  <li>a class with a <code>main</code> method with <code>SpringApplication.run(...)</code> and and annotation with <code>@ImportResource("classpath:META-INF/spring/applicationContext.xml")</code> to import some beans I need when processing the data in the Job.</li>
  </ul>
  
  <p>On the Maven side I am currently using some plugins:</p>
  
  <ul>
  <li><code>maven-jar-plugin</code> specifying <code>&lt;addClasspath&gt;true&lt;/addClasspath&gt;</code> and the class containing the main method in the tag <code>&lt;mainClass&gt;</code></li>
  <li><code>maven-assembly-plugin</code> because I would like a unique executable <code>jar</code> containing all the stuff in the dependencies, I am using <code>&lt;phase&gt;package&lt;/package&gt;</code> to be able to build the jar in the <code>package</code> phase, I am also using <code>&lt;goal&gt;single&lt;/goal&gt;</code> to be able to properly build the jar using the <code>assembly</code></li>
  <li><code>maven-compiler-plugin</code> specifying I am using Java 1.7</li>
  </ul>
  
  <p>I think I've configured all the things I need to configure, however after having a Maven <code>BUILD SUCCESS</code> I am not able to run the job from the command line:</p>
  
  <pre><code>java -cp ./target/JAR_FILE_NAME.jar org.springframework.batch.core.launch.support.CommandLineJobRunner com.package.bla.bla.ClassContainingTheBatchConfiguration nameOfTheJob
  </code></pre>
  
  <p>Is throwing <code>IOException</code> due to the <code>java.io.FileNotFoundException</code> regarding <code>com.package.bla.bla.ClassContainingTheBatchConfiguration</code>. How should I specify the parameters in the command line in order to get the Job executed?</p>