title: UCanAccess relative path to Access database file
body: <p>I have written a simple program for myself which works with an Access database file.
  I used the absolute path to connect to the db:</p>
  
  <pre><code>String path = "jdbc:ucanaccess://D:/Development/20_Eclipse/Budget/data/Budget.accdb";
          Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
          this.conn = DriverManager.getConnection(path);
  </code></pre>
  
  <p>When I use the runnable jar somewhere else this path (understandably) doesn't work. So I tried relative paths but they didn't work either.</p>
  
  <p>Then I tried to build the path using</p>
  
  <pre><code>String path = "jdbc:ucanaccess://" + helper.programmPathForDB() + "/data/Budget.accdb";
  </code></pre>
  
  <p>where <code>helper.programPathForDB()</code> does this:</p>
  
  <pre><code>public String programmPathForDB()
  {
      String tempPath = this.getClass().getResource( "." ).toString();
      String path = tempPath.substring(6, (tempPath.length()-12));
  
      return path;
  }
  </code></pre>
  
  <p>This works ONLY when I start the program through my IDE (Eclipse). When I start the jar somewhere else it doesn't work.</p>
  
  <p>How can I resolve this issue?</p>