Usando o Jasper Assistent atraves do Eclipse 3.2 consegui desenhar o relatorio e até exportar em varios formatos no caso .pdf, O que quero e chamar o arquivo gerado arquivo.jasper atravez do meu aplicativo. Tipo clicar em um botão e chamar o relatorio
privatestaticfinallongserialVersionUID=1L;privateJPaneljContentPane=null;privateJButtonbtAbreRel=null;publicSistemaRelatorio()throwsHeadlessException{super();// TODO Auto-generated constructor stubinitialize();}publicSistemaRelatorio(GraphicsConfigurationgc){super(gc);// TODO Auto-generated constructor stubinitialize();}publicSistemaRelatorio(Stringtitle)throwsHeadlessException{super(title);// TODO Auto-generated constructor stubinitialize();}publicSistemaRelatorio(Stringtitle,GraphicsConfigurationgc){super(title,gc);// TODO Auto-generated constructor stubinitialize();}privateConnectiongetConnection(){Connectioncon=null;try{Stringdriver="org.gjt.mm.mysql.Driver";Stringurl="jdbc:mysql://localhost/livraria";Stringuser="root";Stringpassword="v6d3v6";Class.forName(driver);con=DriverManager.getConnection(url,user,password);}catch(ClassNotFoundExceptioncnf){mostrarErro("Erro ao se conectar");}catch(SQLExceptionsqlex){mostrarErro("Erro ao se conectar");}returncon;}privatevoidabreRelatorio()throwsJRException,Exception{Connectioncon=getConnection();Mapparameters=newHashMap();[b]Stringpath="relatorios/primeiro_relatorio.jasper"[/b];Filefile=newFile(path);file=file.getAbsoluteFile();StringrepStr2=file.getPath();//mostrarErro("Path: "+file);try{JasperFillManager.fillReportToFile(repStr2,parameters,con);JasperPrintjasperPrint=JasperFillManager.fillReport(repStr2,parameters,con);JasperViewerviewer=newJasperViewer(jasperPrint,false);viewer.setVisible(true);}catch(JRExceptionjex){mostrarErro("JasperException: "+jex.getMessage());}catch(Exceptionex){mostrarErro(""+ex.getStackTrace());}}/** * This method initializes btAbreRel * * @return javax.swing.JButton */privateJButtongetBtAbreRel(){if(btAbreRel==null){btAbreRel=newJButton();btAbreRel.setBounds(newjava.awt.Rectangle(78,58,123,40));btAbreRel.setText("Abre Relatório");btAbreRel.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(java.awt.event.ActionEvente){try{abreRelatorio();}catch(JRExceptionjre){mostrarErro("JasperException: "+jre.getMessage());}catch(Exceptionex){mostrarErro(""+ex.getStackTrace());}}});}returnbtAbreRel;}/** * @param args */publicstaticvoidmain(String[]args){newSistemaRelatorio().setVisible(true);}/** * This method initializes this * * @return void */privatevoidinitialize(){this.setSize(300,200);this.setContentPane(getJContentPane());this.setTitle("Relatório de Livros");this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);java.awt.DimensionscreenSize=java.awt.Toolkit.getDefaultToolkit().getScreenSize();java.awt.DimensionframeSize=this.getSize();if(frameSize.height>screenSize.height){frameSize.height=screenSize.height;}if(frameSize.width>screenSize.width){frameSize.width=screenSize.width;}this.setLocation((screenSize.width-frameSize.width)/2,(screenSize.height-frameSize.height)/2);}/** * This method initializes jContentPane * * @return javax.swing.JPanel */privateJPanelgetJContentPane(){if(jContentPane==null){jContentPane=newJPanel();jContentPane.setLayout(null);jContentPane.add(getBtAbreRel(),null);}returnjContentPane;}privatevoidmostrarErro(Stringmsg){JOptionPane.showMessageDialog(null,msg,"Erro encontrado",JOptionPane.ERROR_MESSAGE);}