user1315621 user1315621 - 10 months ago 275
Java Question

Java window builder: runtime error

I create very simple Gui using WindowBuilder plugin for Eclipse. I'm using Swing (maybe a problem?)
I've got plenty of runtime errors:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/jgoodies/common/base/Preconditions
at com.jgoodies.forms.layout.FormSpec.<init>(
at com.jgoodies.forms.layout.ColumnSpec.<init>(
at com.jgoodies.forms.layout.FormSpecs.<clinit>(
at com.jgoodies.forms.layout.LayoutMap.createRoot(
at com.jgoodies.forms.layout.LayoutMap.getRoot(
at com.jgoodies.forms.layout.ColumnSpec.decode(
at it.myweb.project.GUI.TestGUI.initialize(
at it.myweb.project.GUI.TestGUI.<init>(
at it.myweb.project.GUI.TestGUI$
at java.awt.event.InvocationEvent.dispatch(
at java.awt.EventQueue.dispatchEventImpl(
at java.awt.EventQueue.access$500(
at java.awt.EventQueue$
at java.awt.EventQueue$
at Method)
at java.awt.EventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForFilters(
at java.awt.EventDispatchThread.pumpEventsForFilter(
at java.awt.EventDispatchThread.pumpEventsForHierarchy(
at java.awt.EventDispatchThread.pumpEvents(
at java.awt.EventDispatchThread.pumpEvents(
Caused by: java.lang.ClassNotFoundException: com.jgoodies.common.base.Preconditions
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
... 23 more


import java.awt.EventQueue;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.RowSpec;

public class TestGUI {

private JFrame frame;
private JTextField textField;

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

* Create the application.
public ChatGUI() {

* Initialize the contents of the frame.
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 1006, 737);
frame.getContentPane().setLayout(new FormLayout(new ColumnSpec[] {
new RowSpec[] {

JTextArea textArea = new JTextArea();
frame.getContentPane().add(textArea, "1, 1, 2, 1, fill, fill");

textField = new JTextField();
frame.getContentPane().add(textField, "1, 2, fill, center");

JButton btnNewButton = new JButton("Invia");
frame.getContentPane().add(btnNewButton, "2, 2, center, center");

Please note that jgoodies is included in the referenced libraries.

Answer Source

jgoodies jar should be included in runtime classpath of your application. You mention that is is included in referenced libraries, which presumably means that it is on compile classpath, but this is not enough. To include jar on runtime classpath use -cp switch when running java application with command line.