デスクトップ アプリケーションで Jasper レポートを使用しましたが、
なので
void showResports(){
try{
// OriginalExportOriginalExport
String reportName ="";
//ExportReport4.jasperExportReport4.jasper
if(export.equalsIgnoreCase("1")){
reportName = "OriginalExport.jrxml";
}
else if(export.equalsIgnoreCase("0")){
reportName = "ExportReport4.jrxml";
}
InputStream in =getClass().getResourceAsStream(reportName);
if(in==null|| connection==null) return ;
JasperDesign jasperDesign = JRXmlLoader.load(in);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jp = JasperFillManager.fillReport(jasperReport, null, connection);
System.out.println("Object of Jasper Print created");
JRViewer jv = new JRViewer(jp);
//Insert viewer to a JFrame to make it showable
JFrame jf = new JFrame();
jf.getContentPane().add(jv);
jf.validate();
jf.setVisible(true);
jf.setSize(new Dimension(800,600));
jf.setLocation(300,100);
jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
File f=new File(reportName);
if(f.exists()) System.out.println("Yes Yes File is there");
else
System.out.println("File is not there"+f.getAbsolutePath());
}catch(Exception e){
e.printStackTrace();}
}// showReports
}
コンソールで確認すると file not found と表示されるので、なぜこのエラーが発生するのか心配ですが、netebeans ではうまく動作しますか?
今私は得る
C:\Users\FFIS WIN03\dist\report32name_1338142442500_473143.java
at net.sf.jasperreports.engine.design.JRJavacCompiler.compileClasses(JRJavacCompiler.java:89)
at net.sf.jasperreports.engine.design.JRAbstractClassCompiler.compileUnits(JRAbstractClassCompiler.java:63)
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:188)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:212)
at pos.ViewAllPayments$Reporter.showResports(ViewAllPayments.java:1339)
at pos.ViewAllPayments.importButtonActionPerformed(ViewAllPayments.java:1098)
at pos.ViewAllPayments.access$2100(ViewAllPayments.java:39)
at pos.ViewAllPayments$20.actionPerformed(ViewAllPayments.java:448)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.io.IOException: Cannot run program "javac": CreateProcess error= 2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at net.sf.jasperreports.engine.design.JRJavacCompiler.compileClasses(JRJavacCompiler.java:58)
... 43 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 47 more