title: How can I add src/main/resources to the classpath when using mvn exec:java
body: <p>I'm trying to run the following application which attempts to load a file (<code>src/main/resources/test.txt</code>) from the classpath:</p>
  
  <pre><code>package com.example;
  
  public class Main {
      public static void main(String[] args) {
          System.out.println(Main.class.getResource("test.txt"));
      }
  }
  </code></pre>
  
  <p>When I do <code>mvn exec:java -Dexec.mainClass=com.example.Main</code>, I get <code>null</code> printed out on the command line.</p>
  
  <p>So how do I get the files in src/main/resources added to the classpath?  Note that I ran <code>mvn package</code>, checked the generated <code>target/test.jar</code>, and confirmed that it included <code>test.txt</code> at the top level.</p>