0

I'm learning about SWING on intellij. I made a quick app on the GUI designer that contains a button. I compiled it just fine but whenever I run it it throws this error

Exception in thread "main" java.lang.NoClassDefFoundError: com/intellij/uiDesigner/core/GridLayoutManager

Here's the code (I run this file from another main file)

import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * Created by Leon_Clemente on 6/3/15.
 */
public class myFirstTest extends JFrame {
    private JTabbedPane tabbedPane1;
    private JPanel panel1;
    private JButton browseButton;
    private JButton uploadButton;
    private JCheckBox checkBox1;
    private JCheckBox checkBox2;

    public myFirstTest() {
/*
        browseButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                super.mouseClicked(e);
            }
        });
*/
        setVisible(true);
    }

    private void createUIComponents() {
    }
}

So I read on the forums and the only thing I could relate this problem with is that my running classpath is not the same than my compiling classpath(?) I still don't exactly get the idea though.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • Check [this](http://stackoverflow.com/questions/6334148/exception-in-thread-main-java-lang-noclassdeffounderror) out – Avantol13 Jun 04 '15 at 16:22
  • Hello Avantol, I'm not sure what you were trying to show with that post. It mentions how to change the classpath. But I'm starting to think that's not the real problem because the .java file that contains the UI code is in the same path than my main running code. The complete error makes me think it cannot find 'myFirstTest' class, which doesn't make sense to me because the same file its defining it. (?) – César Leonardo Clemente López Jun 04 '15 at 16:42

2 Answers2

1

forms_rt.jar contains GridLayoutManager class and this jar is located in (IntelliJ IDEA Root)\lib. Search for this jar in compile environment.

Add this jar to the class path.

How to set the classpath - setting the path of a jar file

Rajesh
  • 2,135
  • 1
  • 12
  • 14
1

I think you forgot to make main method

Create a new class in same package where myFirstTest is present and try this code:

 public class Main{
     public static void main(String[] args) {

      myFirstTest  myfirst = new myFirstTest();
      myfirst.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      myfirst.setSize(400,400);
      myfirst.setVisible(true);

}
Programmer
  • 445
  • 4
  • 12