-
Java Swings
Can anyone please help me in correcting the following code:
package APackage1;
import java.awt.Container;
import java.util.HashMap;
import net.sf.jasperreports.swing.JRViewer;
import net.sf.jasperreports.engine.*;
public class AViewer extends javax.swing.JFrame
{
public AViewer(String fileName)
{
this(fileName,null);
}
/** 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);
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, 300, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
public AViewer(String fileName,HashMap parameter)
{
super("View Report");
try
{
JasperPrint print = JasperFillManager.fillReport
("C:/Documents and Settings/c.smith/Desktop/Gayu/report2.jasper", parameter);
JRViewer viewer=new JRViewer(print);
Container c=getContentPane();
c.add(viewer);
}
catch(JRException jre)
{
jre.printStackTrace();
}
setBounds(10,10,600,500);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
public static void main(String args[])
{
HashMap parameter=new HashMap();
parameter.put("productID",1);
parameter.put("samplenum",123.55);
parameter.put("sampledt",17/10/2011);
AViewer viewer=new AViewer("C:/Documents and Settings/c.smith/Desktop/Gayu/report2.jasper",parameter);
viewer.setVisible(true);
}
}
// Variables declaration - do not modify
// End of variables declaration
I am trying to display a Jasper Report file through a Java application. In this code, the JFrame is getting loaded, but the report is not. I am getting an error Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException. I dont understand why. This is the first time I am working with Jasper Reports, so please help me. And, am using NetBeans IDE 7.
Thanks.
-
Re: Java Swings
When posting code, please use the highlight tags. See any "read this before posting" article for information on how to do that.
Do you have your classpath set up correctly?