2011-12-07 117 views
2

我在Windows 7 x64上使用eclipse来创建一个新的Java应用程序。javaw.exe在创建JFrame时崩溃

这是我的代码:

 
import java.awt.EventQueue; 


public class Testen { 

    private JFrame frame; 

    /** 
    * Launch the application. 
    */ 
    public static void main(String[] args) { 
     EventQueue.invokeLater(new Runnable() { 
      public void run() { 
       try { 
        Testen window = new Testen(); 
        window.frame.setVisible(true); 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 
      } 
     }); 
    } 

    /** 
    * Create the application. 
    */ 
    public Testen() { 
     initialize(); 
    } 

    /** 
    * Initialize the contents of the frame. 
    */ 
    private void initialize() { 
     System.out.println("1"); 
     frame = new JFrame(); 
     System.out.println("2"); 
     frame.setBounds(100, 100, 450, 300); 
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    } 

} 

我的程序就行了崩溃:

 frame = new JFrame();

它不给任何错误,它只是在等待一两秒钟,然后我的应用程序停止运行。
在事件查看器中我得到这个错误:

Faulting application name: javaw.exe, version: 7.0.10.8, time stamp: 0x4e8975e3 
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000 
Exception code: 0xc0000005 
Fault offset: 0x0000000000000000 
Faulting process id: 0x1334 
Faulting application start time: 0x01ccb4bf9aaa4d8d 
Faulting application path: C:\Program Files\Java\jre7\bin\javaw.exe 
Faulting module path: unknown 
Report Id: d9936f72-20b2-11e1-916b-904ce5de36f8 



Faulting application name: javaw.exe, version: 7.0.10.8, time stamp: 0x4e8975e3 
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000 
Exception code: 0xc000041d 
Fault offset: 0x0000000000000000 
Faulting process id: 0x1334 
Faulting application start time: 0x01ccb4bf9aaa4d8d 
Faulting application path: C:\Program Files\Java\jre7\bin\javaw.exe 
Faulting module path: unknown 
Report Id: dd4f2583-20b2-11e1-916b-904ce5de36f8



Fault bucket 2569546253, type 5 
Event Name: BEX64 
Response: Not available 
Cab Id: 0 

Problem signature: 
P1: javaw.exe 
P2: 7.0.10.8 
P3: 4e8975e3 
P4: StackHash_1dc2 
P5: 0.0.0.0 
P6: 00000000 
P7: 0000000000000000 
P8: c0000005 
P9: 0000000000000008 
P10: 

Attached files: 
C:\Users\jdc\AppData\Local\Temp\WERD617.tmp.WERInternalMetadata.xml 

These files may be available here: 
C:\Users\jdc\AppData\Local\Microsoft\Windows\WER\ReportArchive\AppCrash_javaw.exe_c49c9b915a42e5982f3a993e0cb1afabe4de2bb_168ced10 

Analysis symbol: 
Rechecking for solution: 0 
Report Id: d9936f72-20b2-11e1-916b-904ce5de36f8 



Fault bucket 50876441, type 4 
Event Name: APPCRASH 
Response: Not available 
Cab Id: 0 

Problem signature: 
P1: javaw.exe 
P2: 7.0.10.8 
P3: 4e8975e3 
P4: StackHash_b541 
P5: 0.0.0.0 
P6: 00000000 
P7: c000041d 
P8: 0000000000000000 
P9: 
P10: 

Attached files: 
C:\Users\jdc\AppData\Local\Temp\WEREE86.tmp.WERInternalMetadata.xml 

These files may be available here: 
C:\Users\jdc\AppData\Local\Microsoft\Windows\WER\ReportArchive\AppCrash_javaw.exe_936cbeffcc52c8ea801f518b59b6ee71645a626_1c350580 

Analysis symbol: 
Rechecking for solution: 0 
Report Id: dd4f2583-20b2-11e1-916b-904ce5de36f8 
Report Status: 0

有没有人有任何想法如何解决这个问题?或者我应该从哪里开始寻找解决方案?

编辑:

这在linux下完美无缺。 (最大的区别是java版)

+0

复制粘贴你的代码到Netbeans 7.1 rc1,按预期工作... – Dapeng

+0

它也适用于我的虚拟WinXP测试机器,我想得到它在我的开发机器上工作 – JDC

+0

我有一个完全相同的问题,10个(据称是)同一配置的Windows 7 64位机器上有一个程序,除了实例化一个JFrame之外绝对没有任何东西。 ? –

回答

1

其他Java程序也有我的机器上的烦恼..

一个完整卸载并重新安装所有的Java组件都修复了它。我想我永远不会知道真正的原因.. :-(

2

闲来无事,除了缺少import

import javax.swing.JFrame;

+0

嘿,似乎我忘了复制我的第一行,这是导入javax.swing.JFrame所以这不会帮助我。当导入不存在,程序不会启动..我的程序启动,但EN意想不到的是,即使没有碰到任何东西。的System.out.println( “1”);显示System.out.println(“2”);从未显示。 – JDC

+0

@JDC这个程序在netbeans中为我工作得很好,同时打印了1和2。 – COD3BOY

0
import java.awt.EventQueue; 
import javax.swing.JFrame; 

public class Testen { 

    private JFrame frame; 

    /** 
    * Launch the application. 
    */ 
    public static void main(String[] args) { 
     EventQueue.invokeLater(new Runnable() { 
      public void run() { 
       try { 
        Testen window = new Testen(); 
        window.frame.setVisible(true); 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 
      } 
     }); 
    } 

    /** 
    * Create the application. 
    */ 
    public Testen() { 
     initialize(); 
    } 

    /** 
    * Initialize the contents of the frame. 
    */ 
    private void initialize() { 
     System.out.println("1"); 
     frame = new JFrame(); 
     System.out.println("2"); 
     frame.setBounds(100, 100, 450, 300); 
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    } 

}