title: give fixed path to file in Java project (Netbeans)
body: <p>I have a Java project generating jasper reports, what I do is I give path of a file (report) and run my project it runs fine, but when I have to give JAR file to my friend, it always need that file to be placed in that specific folder according to which my code get's the file path and then have to place file there, my code is below to give some idea</p>
  
  <pre><code>public void generateReport(String dateStart, String dateEnd) {
      InputStream stream = null;
      Connection connection = null;
      Class.forName("com.mysql.jdbc.Driver");
      connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/app", "root", "");
      stream = new FileInputStream(new File("").getAbsolutePath() + "/reports/logReport.jrxml");
      JasperDesign jasperDesign = JRXmlLoader.load(stream);
      jasperReport = JasperCompileManager.compileReport(jasperDesign);
      JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, connection);
  
      //frame.getContentPane().add(dateSetter, BorderLayout.PAGE_START);
      frame.getContentPane().add(new JRViewer300(jasperPrint), BorderLayout.CENTER);
      frame.setResizable(false);
      frame.setSize(900, 600);
      frame.setLocationRelativeTo(null);
      frame.setVisible(true);
      isVisible = true;
      connection.close();
      stream.close();
      }
  </code></pre>
  
  <p>within code it get the file from the path as given </p>
  
  <blockquote>
    <p>/reports/logReport.jrxml</p>
  </blockquote>
  
  <p>but when I put JAR file somewhere else and run it, it gives error that </p>
  
  <blockquote>
    <p>C:\Desktop\reports\logReport.jrxml cannot find path specified. </p>
  </blockquote>
  
  <p>I know it's due to code part <code>new File("").getAbsolutePath()</code> but I need to know how to make it so that it always get the file path from within project! So that I don't always have to place that particular file there!</p>