JDIC 访问Web时NullPointerException
Exception in thread "EventThread" java.lang.NullPointerException
at org.jdesktop.jdic.browser.internal.MsgClient.<init>(Unknown Source)
at org.jdesktop.jdic.browser.internal.NativeEventThread.run(Unknown Source)
该错误原因为pc默认浏览器不是Ie引起的,在声明里设置默认浏览器即可解决。
public class BrowserTest { static { BrowserEngineManager engineManager = BrowserEngineManager.instance(); engineManager.setActiveEngine(BrowserEngineManager.IE); } public static void main(String[] args) throws Exception { WebBrowser browser = new WebBrowser(); browser.setURL(new URL("http://www.baidu.com")); JFrame frame = new JFrame("Browser Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(browser); frame.pack(); frame.setSize(500, 500); frame.setVisible(true); } }