2015-06-02 68 views
0


問有很多疑問在心中是否會因爲這個post可能重複來處理這個問題或不。但是我仍然在這裏問,因爲我沒有發現我的問題完全匹配。異常在線程「AWT-EventQueue的 - 0」 java.lang.IllegalArgumentException異常:該文件不存在

問題是:我無法訪問文件,我在ActionPerformed事件中使用此代碼。的代碼是:

private void asfacd_5_btnActionPerformed(java.awt.event.ActionEvent evt) {            
    File file = new File("‪\\\\Server-bifbtbi\\asfa all\\ASFA DVD 2000 UPTO 2014-Q4\\cdrun.exe"); 
    Desktop dt = Desktop.getDesktop(); 
    try { 
     dt.open(file); 
    } catch (IOException ex) { 
     Logger.getLogger(asfa_cd.class.getName()).log(Level.SEVERE, null, ex); 
    } 
} 

該文件是在一個網絡位置,共享給大家,我可以通過窗口很容易地訪問。

錯誤報告:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: The file: ‪\Server-bifbtbi\asfa all\ASFA DVD 2000 UPTO 2014-Q4\cdrun.exe doesn't exist. 
at java.awt.Desktop.checkFileValidation(Desktop.java:210) 
at java.awt.Desktop.open(Desktop.java:270) 
at asfa_cd.asfacd_5_btnActionPerformed(asfa_cd.java:271) 
at asfa_cd.access$600(asfa_cd.java:18) 
at asfa_cd$6.actionPerformed(asfa_cd.java:135) 
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) 
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346) 
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) 
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) 
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) 
at java.awt.Component.processMouseEvent(Component.java:6527) 
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321) 
at java.awt.Component.processEvent(Component.java:6292) 
at java.awt.Container.processEvent(Container.java:2234) 
at java.awt.Component.dispatchEventImpl(Component.java:4883) 
at java.awt.Container.dispatchEventImpl(Container.java:2292) 
at java.awt.Component.dispatchEvent(Component.java:4705) 
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898) 
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533) 
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462) 
at java.awt.Container.dispatchEventImpl(Container.java:2278) 
at java.awt.Window.dispatchEventImpl(Window.java:2739) 
at java.awt.Component.dispatchEvent(Component.java:4705) 
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746) 
at java.awt.EventQueue.access$400(EventQueue.java:97) 
at java.awt.EventQueue$3.run(EventQueue.java:697) 
at java.awt.EventQueue$3.run(EventQueue.java:691) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86) 
at java.awt.EventQueue$4.run(EventQueue.java:719) 
at java.awt.EventQueue$4.run(EventQueue.java:717) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) 
at java.awt.EventQueue.dispatchEvent(EventQueue.java:716) 
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) 
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) 
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) 
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) 
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) 
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) 

P.S:作爲一個新手我對所有的錯誤代碼非常少的想法,其中不乏我的界。

我真的很感激任何形式的幫助。謝謝你的時間!!!

+0

聯合國軍司令部和網絡路徑不是文件的引用 – MadProgrammer

+0

相同的代碼爲我工作一次。這就是爲什麼我仍然選擇相同的代碼。 Othrwise還有很多其他的選擇我想。即使共享沒有問題,我複製了文件@MadProgrammer – mustangDC

+0

是的,我已經看到類似於Windows 7到SMB共享的工作,並在Windows 8上失敗它是確實是奇蹟,因爲當我開始開發應用程序時,它對我來說工作得很好。今天我只是在特定的框架中添加一個新的'JButton',這就是結果。我猜想一個新按鈕與此無關:| – MadProgrammer

回答

0

嘗試改變\服務器bifbtbi \服務器IP地址

+0

線程中的異常「AWT-EventQueue-0」java.lang.IllegalArgumentException:文件:\ 192.168.0.204 \ asfa all \ ASFA DVD 2000 UPTO 2014-Q4 \ cdrun.exe不存在.' ** IP是正確的**我交叉檢查 – mustangDC

+0

你確定你有previliege訪問文件夾/文件? –

+0

是的,正如我已經明確提到,我可以從我的電腦瀏覽文件。從Network> Server_Bifbtbi>文件位置。 – mustangDC

相關問題