Reputation: 63
Ok, so I was following a tutorial, hoping to create a basic browser I could expand on. In the video, it worked fine, but a lot of people were saying they got this error. I tried it anyway, and I also have it. The error is:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/SWT
And my code is:
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import chrriis.common.UIUtils;
import chrriis.dj.nativeswing.swtimpl.NativeInterface;
import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;
@SuppressWarnings("serial")
public class NeutrinoBrowser extends JFrame {
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
UIUtils.setPreferredLookAndFeel();
NativeInterface.open();
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
NeutrinoBrowser frame = new NeutrinoBrowser();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public NeutrinoBrowser() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
JPanel panel = new JPanel();
contentPane.add(panel, BorderLayout.CENTER);
panel.setLayout(new BorderLayout(0, 0));
final JWebBrowser browserArea = new JWebBrowser();
browserArea.navigate("http://google.com");
panel.add(browserArea, BorderLayout.CENTER);
}
}
I'm using JavaSE 1.8 and the library is The DJ Project Any help is much appreciated. Thanks!
Upvotes: 0
Views: 466
Reputation: 140467
That exception tells you that at run time your class path setup is incomplete.
You are missing the library (aka a JAR file) that contains the SWT library elements.
In case you are using the maven build system, see here for further details.
In case you are not using any build system: consider using one. In the meantime, identify the JAR(s) you need, download them manually and add them to your classpath.
Upvotes: 1