在Neatbeans制造的罐子不起作用

时间:2017-09-25 16:46:26

标签: java swing netbeans

已经研究了很多帮助条目,但没有人帮助我。我是java / netbeans的新手,我认为我的问题的答案很简单(至少我希望如此)。 我毫不费力地在NetBeans中运行我的项目,但是当我" Clean&建立项目"并尝试打开罐子没有任何反应。也尝试使用cmd:

java -jar mapomizer.jar

在构建项目时,只有一个警告:

  

警告:[options] bootstrap类路径未与-source 1.7一起设置

编辑:我的TaskManager有时说java正在运行,但我没看到我的jFrame正在打开。完整代码:

package Mapomizer;

public class Main {

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(JFrame_Choose_Map.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new JFrame_Choose_Map().setVisible(true);
            }
        });
    }

}

1 个答案:

答案 0 :(得分:0)

我不知道Netbeans,但如果你在Eclipse中做同样的事情,你必须指定要显式执行的主类(即使项目中只有一个包含main方法),如果你想让Jar成为可由java -jar或其他方式执行(双击它等)。我想你也必须在Netbeans中这样做,你忘记了。

Google搜索netbeans export jar executable(最后一个词出现为建议),结果中包含一个Netbeans Knowledge Base Article,其中描述了步骤。

您引用的警告与您的问题无关。我敢肯定,如果你谷歌那个消息,将会有很多描述它已经意味着什么; - )

相关问题