Eclipse可以将Java文件导出到.Jar文件中,但会不断出错

Eclipse可以将Java文件导出到.Jar文件中,但会不断出错,java,eclipse,ide,Java,Eclipse,Ide,基本上,Eclipse不能真正导出可执行的java文件。无论何时将其导出并作为.jar文件打开,它都会显示: '无法启动JAVA Jar文件。 检查控制台是否存在可能的错误消息。” 这是代码,忽略“?”标记。它们有实际的文本,而这些只是替代品 private JFrame frame; public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void

基本上,Eclipse不能真正导出可执行的java文件。无论何时将其导出并作为.jar文件打开,它都会显示:

'无法启动JAVA Jar文件。 检查控制台是否存在可能的错误消息。”

这是代码,忽略“?”标记。它们有实际的文本,而这些只是替代品

private JFrame frame;

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Firstone window = new Firstone();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the application.
 */
public Firstone() {
    initialize();
}

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.setBounds(50, 50, 470, 100);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    JButton btnNewButton = new JButton("????");
    btnNewButton.setBounds(190, 40, 76, 29);
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    frame.getContentPane().setLayout(null);
    
    JLabel lblNewLabel = new JLabel("???");
    lblNewLabel.setBounds(18, 18, 432, 16);
    frame.getContentPane().add(lblNewLabel);
    frame.getContentPane().add(btnNewButton);
}
}

我目前一直坚持这个过程,并且已经尝试了论坛帖子上几乎所有的Youtube教程,但找不到正确的解决方案。
这台计算机是一台MacBook,运行macOS Mojave 10.14.6版

在尝试执行
java-jar.jar
时,问题得到了解决。显然,它在
java-jar
之后将文件拖入终端后工作,今天没有出现任何错误。泰姆

“检查控制台是否有可能的错误消息。”意味着您应该通过
java-jar.jar
在命令行上运行它,并检查可能的错误消息。请在该错误消息旁边不仅提供代码片段,还提供一个。请告诉我你从
java-version
中得到了什么。