日期:2014-05-20  浏览次数:20807 次

noclassdeffounderror
package com.pllpwy.Login;
 
public class LoginUI implements ActionListener {
JFrame j;
JLabel jLabel1;
JLabel jLabel2;
JLabel jLabel3;
JLabel jLabel4;
JButton jButton3;
JButton jButton2;
JButton jButton1;
JPasswordField jPasswordField1;
JTextField jTextField1;
Icon i;

public LoginUI() {
j = new JFrame();
//节省空间。代码略。。。
  j.setResizable(false);
j.setLocation(300, 200);
j.setVisible(true);
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public void actionPerformed(ActionEvent e) {

char[] pwd = jPasswordField1.getPassword();
String userpwd = new String(pwd);
String username = jTextField1.getText();

//JOptionPane.showMessageDialog(null, e.getActionCommand());

}

public static void main(String[] args) {
new LoginUI();
}

}


为什么在eclipse下面运行的时候提示:
java.lang.NoClassDefFoundError: com/pllpwy/Login/LoginUI
Caused by: java.lang.ClassNotFoundException: com.pllpwy.Login.LoginUI

它执行的时候,明显执行到了LoginUI文件夹下面去了。这个文件夹肯定不存在的了,这个是邮什么引起的?

------解决方案--------------------
Java code

package com.pllpwy.Login;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class LoginUI implements ActionListener {
JFrame j;
JLabel jLabel1;
JLabel jLabel2;
JLabel jLabel3;
JLabel jLabel4;
JButton jButton3;
JButton jButton2;
JButton jButton1;
JPasswordField jPasswordField1;
JTextField jTextField1;
Icon i;

public LoginUI() {
j = new JFrame();
//节省空间。代码略。。。
  j.setResizable(false);
j.setLocation(300, 200);
j.setVisible(true);
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public void actionPerformed(ActionEvent e) {

char[] pwd = jPasswordField1.getPassword();
String userpwd = new String(pwd);
String username = jTextField1.getText();

//JOptionPane.showMessageDialog(null, e.getActionCommand());

}

public static void main(String[] args) {
new LoginUI();
}

}