运行线程时出现NullPointerException

时间:2014-09-17 09:00:39

标签: java multithreading nullpointerexception cmd jprogressbar

我使用两个不同的threads来提取zip文件并显示JProgressBar。我的第一个线程正常运行,但第二个线程提供NullPointerException

以下是启动两个帖子的代码: -

final String command = System.getProperty("user.dir")+File.separator+"ExtractMe.exe";                
Thread thread1 =  new Thread(){
    public void run() {
        try {
            Runtime.getRuntime().exec("cmd /c "+command);
        } catch (IOException ex) {}                 
    }
};

Thread thread2;
thread2 = new Thread(){
    public void run() {
        new JProgressBarThread();
    }
};    
thread1.start();
thread2.start();

logcat的: -

Exception in thread "Thread-7" java.lang.NullPointerException
    at de.javasoft.plaf.synthetica.SyntheticaRootPaneUI$1.getBorderInsets(SyntheticaRootPaneUI.java:128)
    at de.javasoft.plaf.synthetica.SyntheticaRootPaneUI.installWindowListeners(SyntheticaRootPaneUI.java:147)
    at de.javasoft.plaf.synthetica.SyntheticaRootPaneUI.propertyChange(SyntheticaRootPaneUI.java:273)
    at org.pingalab.splashscr.JProgressBarThread.<init>(Unknown Source)
    at org.pingalab.splashscr.PingalabLauncher$1$2.run(Unknown Source)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at de.javasoft.plaf.synthetica.SyntheticaRootPaneUI$1.getBorderInsets(SyntheticaRootPaneUI.java:128)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.access$400(EventQueue.java:97)

    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    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)

还有一个问题,即使我使用cmd /c运行exe文件开始提取,command window也可见。我该如何隐藏它?

0 个答案:

没有答案