gpt4 book ai didi

java - 从 linux Deepin 15 中的 java 应用程序打印在 jaspersoft studio 中制作的报告时出错

转载 作者:太空宇宙 更新时间:2023-11-04 11:42:56 25 4
gpt4 key购买 nike

我只在 linux 中遇到这个错误,在 Windows 中它运行正常

Linux 目标:Ubuntu 18.04/Deepin 15.11Java版本:1.8.0_221

当我在以下打印对话框中发出打印命令时出现错误:

enter image description here

=========代码

private void testDialogPrint() {

try {

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

Connection connection = DriverManager.getConnection("jdbc:sqlserver://x.x.x.x:1433;databaseName=abc","sa","****");

HashMap<String, Object> params = new HashMap<String,Object>();;

JasperPrint printedReport = JasperFillManager.fillReport("test.jasper", params, connection);

String outputFilename = "Test.pdf";
JasperExportManager.exportReportToPdfFile( printedReport, outputFilename );//file creation success

JasperPrintManager.printReport(printedReport, true);


} catch (ClassNotFoundException | SQLException | JRException e) {
e.printStackTrace();
}

}

=========消息错误

net.sf.jasperreports.engine.JRException: Error printing report.
at net.sf.jasperreports.engine.print.JRPrinterAWT.printPages(JRPrinterAWT.java:215)
at net.sf.jasperreports.engine.JasperPrintManager.print(JasperPrintManager.java:246)
at net.sf.jasperreports.engine.JasperPrintManager.print(JasperPrintManager.java:133)
at net.sf.jasperreports.engine.JasperPrintManager.printReport(JasperPrintManager.java:329)
at com.Start.imprimir(Start.java:46)
at com.Start.main(Start.java:27)
Caused by: java.awt.print.PrinterIOException
at sun.print.PSPrinterJob$PrinterSpooler.run(PSPrinterJob.java:737)
at java.security.AccessController.doPrivileged(Native Method)
at sun.print.PSPrinterJob.endDoc(PSPrinterJob.java:792)
at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1562)
at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1390)
at net.sf.jasperreports.engine.print.JRPrinterAWT.printPages(JRPrinterAWT.java:201)
... 5 more
Caused by: java.io.IOException: Cannot run program "/usr/bin/lpr": error=2, No existe el fichero o el directorio
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:485)
at sun.print.PSPrinterJob$PrinterSpooler.run(PSPrinterJob.java:730)
... 10 more
Caused by: java.io.IOException: error=2, No existe el fichero o el directorio
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 13 more

最佳答案

看起来 Sun JDK 是为/usr/bin/lpr 硬编码的。 - https://kbpdfstudio.qoppa.com/printing-to-pdf-error-message-on-debian-gnulinux-7/

关于java - 从 linux Deepin 15 中的 java 应用程序打印在 jaspersoft studio 中制作的报告时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58720830/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com