Implement ireport with Eclipse java window application

Hello Friends,
Good day!,

I have created jasper report inside Eclipse Luna  java project.. I have imported all the jar files in  'jasperreports-6.0.0\lib' and 'jasperreports-6.0.0\dist'.
But when I export Executable Jar file, it will become more than 50MB file. Also report.jrxml file has not included on it.

I have three questions;

1. What are the exact Jasper jar files to import in Eclipse??

2. How can I include report.jrxml file inside my exported Jar file. It should be secure and user should not able to edit the report

3. How can I display Jasper View inside java swing window object (not a separate window)?

4. What is the proper way to deploy the project with user-non editable package (related to 2nd question)?

Below is my code;

package jasper1;
import jasper1.DB.database;
import java.awt.EventQueue;
import java.sql.Connection;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JLabel;
import net.sf.jasperreports.engine.JRException;
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.view.JasperViewer;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class form1 {
    private JFrame frame;
     * Launch the application.
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    form1 window = new form1();
                } catch (Exception e) {
    Connection conn = null;
    private JTextField text_Host;
    private JTextField text_DB;
    private JTextField text_User;
    private JTextField text_Pwd;
     * Create the application.
    public form1() {
     * Initialize the contents of the frame.
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 450, 300);
        JButton btnNewButton = new JButton("Connect");
        btnNewButton.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                btnNewButton.setText("Please wait...");
            public void mouseReleased(MouseEvent e) {
        btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
       = text_Host.getText();
                database.db = text_DB.getText();
                database.user = text_User.getText();
                database.pwd = text_Pwd.getText();
                conn = DB.Connector();
                if(conn != null){
                    //JOptionPane.showMessageDialog(null, "Successfully Connected");
                    String reportPath = "reports/report.jrxml";
                    try {
                        JasperReport jr = JasperCompileManager.compileReport(reportPath);
                        //JOptionPane.showMessageDialog(null, conn);
                        JasperPrint jp = JasperFillManager.fillReport(jr, null, conn);
                    } catch (Exception e1) {
                        JOptionPane.showMessageDialog(null, e1.getMessage());
        btnNewButton.setBounds(73, 167, 130, 23);
        text_Host = new JTextField();
        text_Host.setBounds(93, 32, 110, 20);
        text_DB = new JTextField();
        text_DB.setBounds(93, 63, 110, 20);
        text_User = new JTextField();
        text_User.setBounds(93, 94, 110, 20);
        text_Pwd = new JTextField();
        text_Pwd.setBounds(93, 125, 110, 20);
        JLabel lblHost = new JLabel("Host");
        lblHost.setBounds(38, 31, 46, 23);
        JLabel lblDatabase = new JLabel("Database");
        lblDatabase.setBounds(38, 63, 56, 20);
        JLabel lblUserName = new JLabel("User Name");
        lblUserName.setBounds(38, 94, 67, 23);
        JLabel lblPassword = new JLabel("Password");
        lblPassword.setBounds(38, 125, 56, 20);

package jasper1;
import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;
public class DB {
    Connection conn = null;
    public static class database {
    public static String host;
    public static String db;
    public static String user;
    public static String pwd;
    public static Connection Connector(){
            Connection conn = DriverManager.getConnection("jdbc:mysql://"":3306/" +database.db ,database.user,database.pwd);
            return conn;
        catch (Exception e){
            JOptionPane.showMessageDialog(null, "Login Failed.\n" +  e);
            return null;

Thank You,


supun151515's picture
Joined: Jan 19 2014 - 3:48am
Last seen: 6 years 8 months ago

1 Answer:

I can only speak from integrating JBOSS 5.1 and Jasper Reports 4+


The files I included were jasperreports-4.0.2.jar jasperreports-fonts-4.0.2.jar jasperreports-javaflow-4.0.2.jar


We build simple templates (.jrxml) and compile to .jasper files. You package the .jasper files into your WAR file or whatever your deployment file is.

Then in your JAVA code, you marry the correct .jasper file to the data you pull from the DB to produce the report.

Depending on how large the data is to use for the report, your user experience will be somewhat uncomfortable.

Example,let's say the data is 100,000 records of "something". When you transform the data to the report, it will take some time so you need to prep the user to understand this.

Here is the flow of what we do:

1. User selects an operation that allows them to pull data back. Usually date driven.

2. This data is displayed in a table (JSP type form )

3. Below this table are icons to generate or export a Jasper PDF or Excel report.

4. User clicks the icon, which goes to another form that informs user that report may take some time. User presses button to confirm or abort.

5. Then pop up a small window informing "report being generated or ????"



al881's picture
Joined: Apr 7 2014 - 4:53pm
Last seen: 7 years 4 months ago

I need help with above 2nd and 3rd questions please

supun151515 - 7 years 5 months ago