java swing运行没反应_java – 无法从命令行运行swing
我在
windows中使用命令行來編譯然后執行我的
java程序.我已經去了
http://java.sun.com/docs/books/tutorial/uiswing/start/compile.html并嘗試編譯HelloWorldSwing.java類.它工作,但當我嘗試“java HelloWorldSwing”它給了我一堆錯誤,并在線程“主”java.lang.NoClassDefFoundError:錯誤的名稱:開始/ HelloWorldSwing中說出一些異常的行.
我嘗試使用java start / HelloWorldSwing運行,它說noClassDefFoundError.我也沒有javac的錯誤.這是教程中的代碼:
import javax.swing.*;
public class HelloWorldSwing {
/**
* 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("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Add the ubiquitous "Hello World" label.
JLabel label = new JLabel("Hello World");
frame.getContentPane().add(label);
//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();
}
});
}
}
編輯:使用javaw
窗口彈出
“發生Java異常”
另一個窗口
“錯誤:無法找到主類.
錯誤:發生了jni錯誤,請檢查您的安裝并重試.“
從來沒有運行任何java程序的任何問題,我錯過了什么?有沒有辦法知道它是什么?
我也在.java和.class所在的同一路徑中運行命令.
我編譯程序的路徑中沒有文件夾啟動.
EDIT2
我用java嘗試了start / HelloWorldSwing和HelloWorldSwing.
我也沒有與javac有任何錯誤.當我使用javaw并且java給我NoClassDefFoundException時,我得到2個彈出窗口,其中包含我之前輸入的消息,然后討論ClassLoaders和諸如此類的東西.
EDIT3
我通過刪除“包開始”讓它工作了線.我需要做些什么來使它與它一起工作?
javaw現在也可以刪除包行.
總結
以上是生活随笔為你收集整理的java swing运行没反应_java – 无法从命令行运行swing的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: es6中map指的是什么意思
- 下一篇: java自动装箱和拆箱_关于java自动