RSS

New to JasperReport : Make it one for all and all for one

27 Feb

Reporting is a critical element that almost every application, either it’s desktop or web based should have. Almost all application developer focused on how to make strong reliable application, but they somewhat forget about this section. Today i will make a basic tutorial for an application that could be integrated into reporting engine, in this case, i will use JasperReport + Java.

Before we start to the core of this tutorial, i will show you how to make your PC/Laptop a “JasperReport-Ready”. Things that you should have to prepare :

1. Netbeans IDE
Netbeans is an integrated development environment (IDE) for Java, PHP, C/C++, Ruby, Python. You can download the latest release here

2. iReport Designer
iReport is a JasperReport designer. With this, you can build your preferable report, design it as your favourite, and integrate it into database. you can download the latest release here

3. JasperReport library
JasperReport is the core engine of reporting library. You can download the library here (need authentication). The dependencies libraries are :

After you’ve done downloaded such many things, let’s make your PC “JasperReport-ready”. Follow these steps :

1. Install Netbeans IDE latest version
2. Install iReport designer
3. Once you’ve installed these 2, follow these special steps :

  • Open your netbeans IDE
  • Click Tools->Libraries as follows :
  • nb-library

    Netbeans IDE

  • A new Library Manager window will appear. Click on New Library.. button
  • Type JasperReport on Library Name (you can use any other name as you like) :

    new-lib

    New Library

  • After that, you will back to Library Manager window. Choose your new jasper report library on Libraries list. Click on Add Jar/Folder button on the right side. Add JasperReport library and all dependencies library. Once it done, you will see a window like this :

    Library Manager

  • Click OK, then your IDE is ready for JasperReport development!

Have Fun!

continue to the next step

 
9 Comments

Posted by on February 27, 2010 in English, Programming

 

Tags: , , , , , , , ,

9 responses to “New to JasperReport : Make it one for all and all for one

  1. Edward

    June 1, 2010 at 12:55 am

    Hans, itu teh kalo dependencies libraries nya yg dimasukkin .jar ato .zip jg gpp pas lg d netbeansnya ?

     
  2. Hans Kristanto

    June 1, 2010 at 7:01 am

    Edward :
    mendingan .jar ajah..tapi kalo misalnya u donlod, nanti dapet nya .jar da.. .jar ini yang u attach ke project u.😀

     
  3. Prashan

    May 7, 2011 at 10:46 pm

    Superb superb…i learnt lot from this…thank you very much

     
  4. Ashutosh sharma

    November 28, 2011 at 4:21 pm

    i want to know how embedded ireports in java desktop application in java netbean IDE and open different-2 reports on button click

     
  5. Ashutosh sharma

    November 28, 2011 at 4:23 pm

    your note r really helpful thanks

     
  6. Tuan Phong

    August 27, 2012 at 9:25 am

    thanks helpful

     
  7. coder

    October 16, 2012 at 9:48 pm

    hi hans, a year back i learn jasper report from your blog. and i done by installing eclipse plugin (it automatically installs irports etc). but now after one year i got requirement to design report again and tried installing eclipse plugin. the plugin gets intalled in eclipse but no jasper studio comes when i click on file–>new–> here it should show “jasper studio” but nothing comes…. whats wrong here… can u please help… i wasted 2 days…

     
  8. Irojah John

    May 22, 2014 at 10:58 pm

    Please and please not intentional to post this problem here.

    Need help on jasper ireport to display on jframe or jpanel .
    The following code show me thise error, please help me through, or
    please link me up to the right java programmer that very good in jasper ireport
    you use to, to help me out on 1 hour training with my project urgently needed,please and please.

    This is the error show when run the project:

    log4j:WARN No appenders could be found for logger (net.sf.jasperreports.engine.xml.JRXmlDigesterFactory).
    log4j:WARN Please initialize the log4j system properly.
    BUILD SUCCESSFUL (total time: 16 seconds).

    After the error:
    The jframe always display or show, so what is the problem please sir.

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    /*
    * Test.java
    *
    * Created on May 3, 2014, 11:43:56 AM
    */
    package schooldata;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import net.sf.jasperreports.engine.JasperCompileManager;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.engine.JasperReport;
    import net.sf.jasperreports.swing.JRViewer;
    import java.sql.SQLException;

    import javax.swing.JFrame;

    /**
    *
    * @author JOFATECH
    */
    public class Test extends javax.swing.JFrame {

    public String url=”jdbc:mysql://localhost/java_school_db”;
    public String username =”root”;
    public String password = “”;

    /** Creates new form Test */
    // private Connection conn = null; // database connection

    public Test() {

    try

    {
    com.mysql.jdbc.Driver driver = new com.mysql.jdbc.Driver();
    DriverManager.registerDriver(driver);

    //jLabel6.setText(“Driver Ok”);
    }
    catch(SQLException ex){

    // JOptionPane.showMessageDialog(ex.printStackTrace());

    }
    // connect to the database

    try

    {
    Connection conn = DriverManager.getConnection(url,username, password);
    try{
    String report =”C:\\Mr John Files\\New Java Project\\Data Entering Systems\\Schooldata\\src\\reportes\\report10.jrxml”;
    JasperReport jr = JasperCompileManager.compileReport(report);
    JasperPrint jp = JasperFillManager.fillReport(jr, null, conn);
    //JasperViewer.viewReport(jp);
    JRViewer viewer = new JRViewer(jp);
    JFrame jf = new JFrame();
    jf.add(viewer);
    setVisible(true);
    }
    catch(Exception ex){

    }

    // jLabel6.setText(“Connection Ok”);
    }
    catch(Exception ex)
    {

    //JOptionPane.showMessageDialog(ex.printStackTrace());

    }
    setSize(500, 600);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }

    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    */
    @SuppressWarnings(“unchecked”)
    //
    private void initComponents() {

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setName(“Form”); // NOI18N
    addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowOpened(java.awt.event.WindowEvent evt) {
    formWindowOpened(evt);
    }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 400, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 339, Short.MAX_VALUE)
    );

    pack();
    }//

    private void formWindowOpened(java.awt.event.WindowEvent evt) {
    // TODO add your handling code here:
    this.setLocationRelativeTo(null);
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
    * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
    */
    try {
    for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
    if (“Nimbus”.equals(info.getName())) {
    javax.swing.UIManager.setLookAndFeel(info.getClassName());
    break;
    }
    }
    } catch (ClassNotFoundException ex) {
    java.util.logging.Logger.getLogger(Test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
    java.util.logging.Logger.getLogger(Test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
    java.util.logging.Logger.getLogger(Test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
    java.util.logging.Logger.getLogger(Test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {

    public void run() {
    new Test().setVisible(true);
    }
    });
    }
    // Variables declaration – do not modify
    // End of variables declaration
    }

    Please and please guru help me with this problem.Have been facing this challenge for
    more than 6 months. Please programmers help me out.
    My Phone number is:+2348059732964
    Thank for helping me.

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: