导出后出现Java Eclipse Project问题

时间:2012-07-09 08:09:53

标签: java eclipse

我已经为学校做了几周的Java项目,几天前我完成了它。它是一个数据库管理员软件,用于运行Access数据库,在本例中是我学校的数据库。在Eclipse IDE中,所有工作正常,0错误,0警告显示。然后当我导出导出时我也没有得到任何错误,但是当我打开项目时,菜单的6个按钮中只有2个工作。菜单有6个按钮。 5与Access连接并显示不同的数据,其中只有一个工作,其他选项卡用于退出按钮。因此,我在cmd中运行导出的程序以获得更精确的错误,并弹出此日志。

C:\Users\IVAN>java -jar prueba.jar
consulta busar registro: SELECT * FROM StudentsAbsences ORDER BY Id;
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at javax.swing.ImageIcon.<init>(Unknown Source)
        at ModificarAlumno.getCancelar_btn(ModificarAlumno.java:199)
        at ModificarAlumno.getJContentPane(ModificarAlumno.java:385)
        at ModificarAlumno.initialize(ModificarAlumno.java:310)
        at ModificarAlumno.<init>(ModificarAlumno.java:298)
        at Menu$4.actionPerformed(Menu.java:127)
        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 Sour
ce)
        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$000(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$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        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$1.doIntersectionPrivilege(Unknown Sour
ce)
        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)

我是stackoverflow中的新手,并且从未使用过这个问答网页,所以我不确定我是否必须发布其他内容。我得到了星期二的工作项目,所以我非常匆忙。任何帮助表示赞赏,如果您需要有关该项目的更多信息,请告诉我,我会尽快发布。非常感谢你。

2 个答案:

答案 0 :(得分:1)

看起来下面的代码抛出了NullPointerException。

    at javax.swing.ImageIcon.<init>(Unknown Source)
    at ModificarAlumno.getCancelar_btn(ModificarAlumno.java:199)

这意味着在ModificarAlumno.getCancelar_btn()中您正在构建一个新的ImageIcon,并在其构造函数内抛出异常。可能是导出后图像没有正确加载?如果没有帮助,请发布其他代码。

答案 1 :(得分:0)

如果程序在Eclipse内部工作但不在外部,请检查两件事:

  1. 在代码中查找您在文件系统上硬编码位置的位置,以获取图像和其他文件等内容。在另一台计算机上,这些位置可能会发生变化。

  2. 将jar默认导出为java类。如果您有非Java文件属于该程序,请确保配置导出和构建向导以导出/构建这些文件。