mercredi 25 février 2015

Why do I get a NoSuchFieldError exception in Java?

I'm trying to display any website using Eclipse internal browser.


Here's the code I'm trying:



public class WebTest {

public static void main(String[] args) {
NativeInterface.open();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame("YouTube Viewer");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.getContentPane().add(getBrowserPanel(),
BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
});
NativeInterface.runEventPump();
// don't forget to properly close native components
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
NativeInterface.close();
}
}));
}

public static JPanel getBrowserPanel() {
JPanel webBrowserPanel = new JPanel(new BorderLayout());
JWebBrowser webBrowser = new JWebBrowser();
webBrowserPanel.add(webBrowser, BorderLayout.CENTER);
webBrowser.setBarsVisible(false);
webBrowser.navigate("http://ift.tt/1DVqgBB");
return webBrowserPanel;
}
}


However, when I try to run it, I get the following exception:



Exception in thread "main" java.lang.NoSuchFieldError: DEPENDENCIES_CHECKVERSIONS
at chrriis.dj.nativeswing.swtimpl.NSSystemPropertySWT.<clinit>(NSSystemPropertySWT.java:94)
at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.<clinit>(SWTNativeInterface.java:86)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at chrriis.dj.nativeswing.swtimpl.internal.NativeCoreObjectFactory.create(NativeCoreObjectFactory.java:38)
at chrriis.dj.nativeswing.swtimpl.NativeInterface.<clinit>(NativeInterface.java:22)
at WebTest.main(WebTest.java:14)


So there is clearly something wrong with my dependencies... But I'm not sure how do I fix this, I have included all necessary jars:


enter image description here


Any ideas?





Aucun commentaire:

Enregistrer un commentaire