title: Understanding the basics of Jasper reporting with Java
body: <p>I am just starting learning <code>Jasper reports</code> with <code>Java</code>. I searched through the web and did not find a good tutorial which teaches reporting from the very beginning. Tutorialspoint.com have a good one, but they use <code>ANT</code> for that. I can learn them after, but what I need now is to generate <code>jasper reports</code> using simple Java programs. 
  I found a code from <code>github</code> which is <a href="https://gist.github.com/rponte/5044469" rel="nofollow">here</a>, but I have some issues with understanding that code. </p>
  
  <pre><code>            String reportName = "myreport";
              Map&lt;String, Object&gt; parameters = new HashMap&lt;String, Object&gt;();
              connection = new ConnectionFactory().getConnection(); // opens a jdbc connection
  
              // compiles jrxml
              JasperCompileManager.compileReportToFile(reportName + ".jrxml");
              // fills compiled report with parameters and a connection
              JasperPrint print = JasperFillManager.fillReport(reportName + ".jasper", parameters, connection);
              // exports report to pdf
              JRExporter exporter = new JRPdfExporter();
              exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
              exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, new FileOutputStream(reportName + ".pdf")); // your output goes here
  
              exporter.exportReport();
  </code></pre>
  
  <p>It generates the report using above code. But, there are some parts where I find some issues when understanding.</p>
  
  <ul>
  <li>Where is the Query String?</li>
  <li>Do I have to create the <code>jrxml</code> file separately, which contains the query string and name that file as <code>myreport.jrxml</code>?</li>
  </ul>
  
  <p>Thank you!</p>