Good afternoon Sirs! Home
I'm having a problem and none of the other posts could help me ...
I was checking my TCC and I just came across the following problem: My .JAR executable can not identify the folder where the reports created by iReport version 5.6.0 are. Home
In my project, I have a .integrado.reports folder where I save all my .jasper and have already imported the iReport libraries into the project. Home
This is my code for "printing" the report:
public class RelatorioService {
private static final String FOLDER = "/br/integrado/reports";
public void gerarRelatorio(HashMap parametros, String nomeRelatorioJasper) throws JRException {
String caminhoRelatorio = this.getClass().getResource(FOLDER).getPath();
String caminhoArquivosJasper = caminhoRelatorio + File.separator + nomeRelatorioJasper + ".jasper";
JasperReport relatorioJasper = (JasperReport) JRLoader.loadObjectFromFile(caminhoArquivosJasper);
JasperPrint impressoraJasper = JasperFillManager.fillReport(relatorioJasper, parametros, ConexaoJDBC.getConexao());
JasperViewer jrv = new JasperViewer(impressoraJasper, false);
jrv.setVisible(true);
jrv.toFront();
}
}
In netbeans it works perfectly, however in .jar it gives me the following exception by CMD:
nov 25, 2018 2:04:00 PM br.integrado.view.RelListagemClienteView jButton1ActionPerformed
GRAVE: null net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: file: \ C: \ Users \ willz \ Documents \ GitHub \ TCC \ StoreSoft \ dist \ StoreSoft.jar! \ br \ integrated \ reports \ ListReportsReport.jasper at net.sf.jasperreports.engine.util.JRLoader.loadObject (JRLoader.java:114) at net.sf.jasperreports.engine.util.JRLoader.loadObject (JRLoader.java:103) at net.sf.jasperreports.engine.util.JRLoader.loadObjectFromFile (JRLoader.java:94) at br.integrado.reports.RelatorioService.gerarReport (RelatorioService.java:33) at.integrated.view.RelListCustomView.printRate (Relate ListView.java:269) at.integrated.view.RelListenerClientView.jButton1ActionPerformed (Relate ListView.java:197) at.integrated.view.RelListenerClientView.access $ 300 (RelListCustomView.java:24) at.integrated.view.RelListenerClientView $ 4.actionPerformed (RelListCustomView.java:136) 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 $ 500 (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 $ JavaSecurityAccessImpl.doIntersectionPrivilege (Unknown Source) at java.security.ProtectionDomain $ JavaSecurityAccessImpl.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 $ JavaSecurityAccessImpl.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.FileNotFoundException: file: \ C: \ Users \ willz \ Documents \ GitHub \ TCC \ StoreSoft \ dist \ StoreSoft.jar! \ Br \
Could anyone help me?