java swing运行没反应_java – 无法从命令行运行swing

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 17:32   1862   0

我在

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现在也可以删除包行.

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP