0
以下是完整的錯誤消息:爲什麼我得到這個錯誤?異常在線程 「主要」 java.lang.NoClassDefFoundError:「
Exception in thread "main" java.lang.NoClassDefFoundError: DataEntry/java
Caused by: java.lang.ClassNotFoundException: DataEntry.java
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
這裏是我的代碼:
import java.awt.*;
import java.awt.event.*;
public class DataEntry {
public static void main(String[] args) {
Frame frm=new Frame("DataEntry frame");
Label lbl = new Label("Please fill this blank:");
frm.add(lbl);
frm.setSize(350,200);
frm.setVisible(true);
frm.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
Panel p = new Panel();
Panel p1 = new Panel();
Label jFirstName = new Label("First Name");
TextField lFirstName = new TextField(20);
Label jLastName =new Label("Last Name");
TextField lLastName=new TextField(20);
p.setLayout(new GridLayout(3,1));
p.add(jFirstName);
p.add(lFirstName);
p.add(jLastName);
p.add(lLastName);
Button Submit=new Button("Submit");
p.add(Submit);
p1.add(p);
frm.add(p1,BorderLayout.NORTH);
}
}
文件被保存因爲DataEntry.java和DataEntry.class文件位於同一個目錄中。有人可以告訴我我做錯了什麼嗎?
您的代碼此處無關緊要。你是如何編譯的? – Dici 2014-09-30 23:27:44
更具體地說,你是如何嘗試開始你的課程? – Krease 2014-09-30 23:31:58