title: How to define a relative path in java
body: <p>Here is the structure of my project :</p>
  
  <p><img src="https://i.stack.imgur.com/vPYrU.png" alt="here is the structure of my project"></p>
  
  <p>I need to read <code>config.properties</code> inside <code>MyClass.java</code>.
  I tried to do so with a relative path as follows :</p>
  
  <pre><code>// Code called from MyClass.java
  File f1 = new File("..\\..\\..\\config.properties");  
  String path = f1.getPath(); 
  prop.load(new FileInputStream(path));
  </code></pre>
  
  <p>This gives me the following error :</p>
  
  <pre class="lang-none prettyprint-override"><code>..\..\..\config.properties (The system cannot find the file specified)
  </code></pre>
  
  <p>How can I define a relative path in Java? I'm using jdk 1.6 and working on windows.</p>