Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Swing / AWT / SWT
Jasper Report Not Working when i run it from executable jar file
Moath Hamdan
Greenhorn
Posts: 2
posted 7 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Imported library's which I am using:
My code .. it is working when I run it in Eclipse: package report; import java.util.HashMap; import java.util.List; import javax.swing.table.DefaultTableModel; import mais.moath.db.InsertList; import net.sf.jasperreports.engine.*; import net.sf.jasperreports.engine.data.JRTableModelDataSource; import net.sf.jasperreports.view.JasperViewer; public class PrintReport { public PrintReport(List<InsertList> list){ ///////////////////////////////// try{ JasperReport report = JasperCompileManager.compileReport("D:\\mais\\supervisor.jrxml"); DefaultTableModel tableModel; String[] columnNames = {"name", "grade", "section", "subject", "evaluation", "date", "reason" ,"term"}; int row = 0; row = list.size(); String[][] data = new String[row][columnNames.length]; for(int i = 0 ; i < row ; i++){ for(int j = 0 ; j < columnNames.length ; j++){ switch(j){ case 0: data[i][j] = list.get(i).getName(); break; case 1: data[i][j] = list.get(i).getGrade(); break; case 2: data[i][j] = list.get(i).getSection(); break; case 3: data[i][j] = list.get(i).getSubject(); break; case 4: data[i][j] = list.get(i).getEvaluation(); break; case 5: data[i][j] = list.get(i).getDate(); break; case 6: data[i][j] = list.get(i).getReason(); break; case 7: data[i][j] = list.get(i).getTerm(); break; } } } tableModel = new DefaultTableModel(data, columnNames); JasperPrint jasperPrint = JasperFillManager.fillReport(report, new HashMap(),new JRTableModelDataSource(tableModel)); JasperViewer jasperViewer = new JasperViewer(jasperPrint); jasperViewer.setVisible(true); }catch(Exception e){ e.printStackTrace(); // ErrorFile.setError(e.toString()); } ///////////////////////////////// } }
When run JAR file from cmd I got the following result:
K. Tsang
Bartender
Posts: 3648
16
I like...
posted 7 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Welcome to the Ranch
How are you exporting the jar file? Are the libraries included in the jar and the class path specified in the manifest file?
K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
Moath Hamdan
Greenhorn
Posts: 2
posted 7 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
yes .. jar files included in executable jar file
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Jasperreports prints with incorrect paper size
Jtable Cell and ENTER key
JasperReport, generate Docx without Data
JTable - how can I repaint it with updated data
JTable problem
More...