简体   繁体   English

用 Neatbeans 制作的罐子不起作用

[英]jar made in Neatbeans doesnt work

already researched many help entries but none helped me.已经研究了许多帮助条目,但没有一个帮助我。 I'm new to java/netbeans and i think the answer on my question is quite simple (at least i hope it).我是 java/netbeans 的新手,我认为我的问题的答案很简单(至少我希望如此)。 I ran my project in NetBeans without difficulties, but when i "Clean & Build the project" and try to open the jar nothing happens.我在 NetBeans 中运行我的项目没有任何困难,但是当我“清理并构建项目”并尝试打开 jar 时没有任何反应。 Also tried with cmd:也用cmd尝试过:

java -jar mapomizer.jar

There only has been one warning, when building the project:构建项目时只有一个警告:

warning: [options] bootstrap class path not set in conjunction with -source 1.7警告:[options] 引导类路径未与 -source 1.7 一起设置

Edit: My TaskManager sometimes says java is running, but i dont see my jFrame being opend.编辑:我的 TaskManager 有时会说 java 正在运行,但我没有看到我的 jFrame 正在打开。 Here full code:这里完整的代码:

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);
            }
        });
    }

}

I don't know Netbeans but if you do the same in Eclipse you have to specify the main class to be executed explicitly (even if there is only one in the project containing a main-method) if you want the Jar being executable by java -jar or other means (double clicking on it, etc).我不知道 Netbeans 但如果你在 Eclipse 中做同样的事情你必须指定要显式执行的主类(即使项目中只有一个包含主方法)如果你想让 Jar 被java -jar或其他方式(双击它等)。 I suppose you have to do that in Netbeans as well and you forgot that.我想您也必须在 Netbeans 中这样做,而您忘记了这一点。

Googling for netbeans export jar executable (the last word came up as suggestion) the result contains a Netbeans Knowledge Base Article where the steps are described.谷歌搜索netbeans export jar executable (最后一个词作为建议出现)结果包含描述步骤的Netbeans 知识库文章

The warning you quoted has nothing to do with your problem.您引用的警告与您的问题无关。 I'm sure if you google that message, there will be plenty of descriptions what it means already ;-)我敢肯定,如果您在 google 上搜索该消息,就会有很多说明已经是什么意思了 ;-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM