這裏是我的代碼,錯誤:無法找到或加載主類FrameDemo?
package components;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/* FrameDemo.java requires no other files. */
public class FrameDemo {
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("FrameDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel emptyLabel = new JLabel("");
emptyLabel.setPreferredSize(new Dimension(175, 100));
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
//Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
我複製這從Oracle網站與複製和粘貼一字不差。 Here
這就是我在命令提示符下所做的事情嗎?這裏有什麼問題。我嚴肅地對待自己的結局。
Directory of C:\Users\headgearxthree\Desktop\SCRAP\JAVA\compile\gui
12/17/2016 12:42 PM <DIR> .
12/17/2016 12:42 PM <DIR> ..
12/17/2016 12:29 PM 2,765 FrameDemo.java
1 File(s) 2,765 bytes
2 Dir(s) 51,945,787,392 bytes free
C:\Users\headgearxthree\Desktop\SCRAP\JAVA\compile\gui>javac Framedemo.java
C:\Users\headgearxthree\Desktop\SCRAP\JAVA\compile\gui>java -cp . FrameDemo
Error: Could not find or load main class FrameDemo
C:\Users\headgearxthree\Desktop\SCRAP\JAVA\compile\gui>
我發了一個Hello World!就在之前在其父目錄中編程,沒有任何問題。這個錯誤是什麼?出了什麼問題?這些例子應該簡單而雄辯。這是一個簡單的方法,但只要涉及圖形,所有窗口上的編程都會轉到sh * t。跆拳道?這不是重複的。所有相似的問題都參考了一個特定的實例我以無黨派的方式說過這句話,所以它可以幫助很多人。請不要鎖定。
什麼班段嗎? –
這個java風格是一種痛苦。謝謝。 –