简体   繁体   中英

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). I ran my project in NetBeans without difficulties, but when i "Clean & Build the project" and try to open the jar nothing happens. Also tried with 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

Edit: My TaskManager sometimes says java is running, but i dont see my jFrame being opend. 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). I suppose you have to do that in Netbeans as well and you forgot that.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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