title: FileNotFoundException starting jar - can't see file in resources folder
body: <p>I want that my application will be OS independent. Therefore my config.properties and log file are stored in resources folder and I get these resources with relative path. 
  Here is my project structure.<img src="https://i.stack.imgur.com/KtNzT.png" alt="project structure"></p>
  
  <p>Here is my AppConfig class:</p>
  
  <pre><code>public final class AppConfig {
  
  private static final String RELATIVE_PATH_TO_PROPERTIES = "./src/main/resources/config.properties";
  public static final String RELATIVE_LOG_PATH = "./src/main/resources/err_action.log";
  
  private static Properties props = initProperties();
  public static final String HOST = props.getProperty("ip_address");
  
  public static final int PORT = Integer.valueOf(props.getProperty("port"));
  public static final int MAX_USERS = Integer.valueOf(props.getProperty("max_number_of_users"));
  public static final int NUM_HISTORY_MESSAGES = Integer.valueOf(props.getProperty("last_N_messages"));
  
  private static Properties initProperties() {
      Properties properties = null;
      try (FileInputStream input = new FileInputStream(RELATIVE_PATH_TO_PROPERTIES)) {
          properties = new Properties();
          properties.load(input);
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
      return properties;
  }
  }
  </code></pre>
  
  <p>As you can see, I specify relative path for properties and log files.
  I create jar with maven and when I run it, I receive </p>
  
  <blockquote>
    <p>java.io.FileNotFoundException: ./src/main/resources/err_action.log (No such file or directory)</p>
  </blockquote>
  
  <p><strong>UPD</strong>
  Here is my <strong>pom.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0          http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;chat&lt;/groupId&gt;
  &lt;artifactId&gt;Client-Chat&lt;/artifactId&gt;
  &lt;version&gt;1.0&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  &lt;properties&gt;
      &lt;java_version&gt;1.8&lt;/java_version&gt;
  &lt;/properties&gt;
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.11&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;${java_version}&lt;/source&gt;
                  &lt;target&gt;${java_version}&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.4&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;archive&gt;
                      &lt;manifest&gt;
                          &lt;mainClass&gt;nikochat.com.app.Main&lt;/mainClass&gt;
                          &lt;!--&lt;mainClass&gt;nikochat.com.app.RunClient&lt;/mainClass&gt;--&gt;
                      &lt;/manifest&gt;
                  &lt;/archive&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
      &lt;/plugins&gt;
  &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I use Intellij Idea and run maven <strong>package</strong> command, result of which is next output:</p>
  
  <blockquote>
    <p>[INFO] Scanning for projects... [INFO]
    ------------------------------------------------------------------------ [INFO] Building Unnamed - chat:Server-Chat:jar:1.0 [INFO]<br>
    task-segment: [package] [INFO]
    ------------------------------------------------------------------------ [INFO] [resources:resources {execution: default-resources}] [WARNING]
    Using platform encoding (UTF-8 actually) to copy filtered resources,
    i.e. build is platform dependent! [INFO] Copying 2 resources [INFO]
    [compiler:compile {execution: default-compile}] [INFO] Nothing to
    compile - all classes are up to date [INFO] [resources:testResources
    {execution: default-testResources}] [WARNING] Using platform encoding
    (UTF-8 actually) to copy filtered resources, i.e. build is platform
    dependent! [INFO] skip non existing resourceDirectory
    /home/nikolay/IdeaProjects/Chat/src/test/resources [INFO]
    [compiler:testCompile {execution: default-testCompile}] [INFO] Nothing
    to compile - all classes are up to date [INFO] [surefire:test
    {execution: default-test}] [INFO] Surefire report directory:
    /home/nikolay/IdeaProjects/Chat/target/surefire-reports</p>
    
    <p>-------------------------------------------------------  T E S T S
    ------------------------------------------------------- Running AppConfigTest Tests run: 2, Failures: 0, Errors: 0, Skipped: 2, Time
    elapsed: 0.129 sec</p>
    
    <p>Results :</p>
    
    <p>Tests run: 2, Failures: 0, Errors: 0, Skipped: 2</p>
    
    <p>[INFO] [jar:jar {execution: default-jar}] [INFO] Building jar:
    /home/nikolay/IdeaProjects/Chat/target/Server-Chat-1.0.jar [INFO]
    ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO]
    ------------------------------------------------------------------------ [INFO] Total time: 11 seconds [INFO] Finished at: Mon Sep 08 09:47:18</p>
    
    <h2>EEST 2014 [INFO] Final Memory: 18M/154M [INFO]</h2>
  </blockquote>
  
  <p>at the beginning I create Server-Chat jar for running server part of application, than I change artifactId to Client-Chat and manifest mainClass to create client part of application.
  Both parts I run in terminal typing command:
  <strong>java</strong> <strong>-jar</strong> <strong>Server-Chat-1.0.jar</strong> or <strong>java</strong> <strong>-jar</strong> <strong>Client-Chat-1.0.jar</strong> respectively.</p>
  
  <p>Here is the output of server:</p>
  
  <blockquote>
    <p>java.io.FileNotFoundException: config.properties (No such file or directory)
            at java.io.FileInputStream.open(Native Method)</p>
  </blockquote>
  
  <p>And client:</p>
  
  <blockquote>
    <p>eaProjects/Chat/target $ java -jar Client-Chat-1.0.jar 
    java.io.FileNotFoundException: config.properties (No such file or directory)</p>
  </blockquote>