如何修复“ java.lang.ClassNotFoundException:net.miginfocom.swing.MigLayout”?

时间:2019-09-28 00:32:52

标签: java miglayout

我想使用MigLayout,然后按照以下步骤在Eclipse IDE中导入jar文件(

  • 右键单击您的项目,
  • 选择构建路径,
  • 点击“配置构建路径”,
  • 单击“库”,然后选择“添加外部JAR”,
  • 从所需文件夹中选择jar文件,
  • 单击并应用,然后确定)

我认为问题不在我的代码中,但让我在这里写下。

package learning;

import javax.swing.*;

import net.miginfocom.swing.MigLayout;

public class RegistrationWindow extends JFrame {

public RegistrationWindow() {
    setSize(200,200);
    setTitle("User registration");
    setLocationRelativeTo(null);
    setResizable(true);
    JPanel panel = new JPanel();
    JLabel fName = new JLabel("First name ");
    JLabel lName = new JLabel("Last name ");
    JTextField field1 = new JTextField();
    JTextField field2 = new JTextField();
    panel.setLayout(new MigLayout());
    panel.add(fName);
    panel.add(field1);
    panel.add(lName);
    panel.add(field2);


}

}    

我得到的错误是

Error:
    Exception in thread "main" java.lang.NoClassDefFoundError: net/miginfocom/swing/MigLayout
    at learning.RegistrationWindow.<init>(RegistrationWindow.java:10)
    at learning.Registration.main(Registration.java:8)
Caused by: java.lang.ClassNotFoundException: net.miginfocom.swing.MigLayout
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 2 more

我在这里想念什么?

0 个答案:

没有答案