如何使用Eclipse IDE创建可执行jar?

时间:2015-04-03 08:42:10

标签: java eclipse swing jar executable-jar

您好我是使用Eclipse IDE开发Swing应用程序的新手。 我正在使用java sdk 1.7和Ubuntu 12.04操作系统。还使用Eclipse IDE版本:Luna Service Release 1a(4.4.1)。

当我尝试使用以下步骤创建可执行jar时 - 1-正确保存项目。 2-右键单击项目,然后单击导出。 3.单击java标记 4.单击Runnable Jar文件 5.成功导出jar文件。在谷歌搜索概念后。

每当我打开此文件窗口7操作系统环境时 正在显示错误

could not find the main class <class name>. program will exit.

我检查了主类.MF文件。阶级存在。为什么要显示此错误?

public class Start {

private JFrame frame;

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

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

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 450, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel lblHiIaM = new JLabel("Hi i am a example");
    frame.getContentPane().add(lblHiIaM, BorderLayout.CENTER);
}

}

此代码在IDE中成功运行。 我需要创建一个可安装的项目exe文件。

请尽可能帮助我。 我病得很严重。 感谢

0 个答案:

没有答案
相关问题