编译报告时出错:java.lang.NoClassDefFoundError:javax / servlet / ServletOutputStream [英] Error Compiling Report: java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream

查看:2366
本文介绍了编译报告时出错:java.lang.NoClassDefFoundError:javax / servlet / ServletOutputStream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编译报告时出错,错误是:

I have an error while compiling report the error is:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream

这是代码:

Map parameter = new HashMap();
parameter.put("customerId", notification_table.getValueAt(r, 0).toString());
ReportV sd = new ReportV();
sd.showReport(parameter);

这是我使用的课程:

import java.sql.*;
import java.util.Map;
import javax.swing.*;

import static javax.swing.JFrame.EXIT_ON_CLOSE;

import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.swing.JRViewer;

public class ReportV {

    Connection conn = null;

    void showReport(Map parameters) {
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            conn = DriverManager.getConnection("jdbc:odbc:pcn");
            JasperReport report = JasperCompileManager.compileReport("recipt.jrxml");
            JasperPrint print = JasperFillManager.fillReport(report, parameters, conn);
            JRViewer viewer = new JRViewer(print);
            viewer.setOpaque(true);
            viewer.setVisible(true);
            //make your JFrame visible
            this.add(viewer);
            this.setSize(300, 200);
            this.setVisible(true);
            this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        } catch (Exception ex) {
            System.out.println("CAUSE: " + ex.getCause());
            System.out.println("MESSAGE" + ex.getMessage());
            System.out.println("LOCAL MESSAGE" + ex.getLocalizedMessage());
            ex.printStackTrace();
        }
    }
}


推荐答案

您尚未导入 ServletOutputStream 类。

import javax.servlet.ServletOutputStream;

我相信这是Java EE的一部分,所以你需要在类路径中使用lib而不是标准java jdk。

I believe that's part of Java EE, so you will need that lib in your classpath in addition to the standard java jdk.

这篇关于编译报告时出错:java.lang.NoClassDefFoundError:javax / servlet / ServletOutputStream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆