2012-07-09 156 views
0

我一直在爲學校做這個Java項目幾周,並在幾天前完成它。它是一個數據庫管理員軟件,用於運行Access數據庫,在這種情況下,我的學校的數據庫。在Eclipse IDE中,所有工作正常,0錯誤,0警告顯示。然後,當我導出導出時,我也沒有得到任何錯誤,但是當我打開該項目時,菜單的6個按鈕中只有2個工作。菜單有6個按鈕。 5與Access連接並顯示不同的數據,其中只有其中一個工作,另一個工作於其退出按鈕的選項卡。所以我在cmd中運行導出的程序以獲得更精確的錯誤,並且此日誌彈出。導出後Java Eclipse項目的問題

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

發佈'ModificarAlumno.getCancelar_btn()'的代碼,並解釋加載圖像的位置。 – 2012-07-09 08:14:09

回答

1

它看起來像下面的代碼拋出NullPointerException。

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

這意味着,在ModificarAlumno.getCancelar_btn()你正在建設一個新的ImageIcon,它的構造函數中的異常被拋出。難道是出口後圖像沒有被正確加載?如果這不起作用,請發佈其他代碼。

0

如果該程序運行在Eclipse但不是外面,檢查兩件事情:

  1. 查找在你的代碼,你硬編碼在文件系統中的東西像圖像和其他文件的位置的地方。在另一臺電腦上,這些位置可能會發生變化。

  2. 導出jar默認只是java類。如果您的程序中包含非java文件,請確保您配置了導出並構建嚮導以導出/構建這些文件。