2017-09-25 69 views
-1

已經研究了許多幫助條目,但沒有人幫助我。我是java/netbeans的新手,我想我的問題的答案很簡單(至少我希望它)。 我在NetBeans中運行我的項目沒有任何困難,但是當我「清潔&構建項目」並嘗試打開該jar沒有任何反應。還與CMD嘗試:在Neatbeans製造的罐子不工作

java -jar mapomizer.jar 

有隻得到了一個警告,建設項目時:

警告:【選項】結合不設置與-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); 
      } 
     }); 
    } 

} 
+0

什麼是錯誤? – Ravi

+0

什麼是JFrame_Choose_Map?爲了儘快提供更好的幫助,請發佈[MCVE]或[簡短,獨立,正確的示例](http://www.sscce.org/)。 –

+0

您是否設置了該項目的主類屬性? – MadProgrammer

回答

0

我不知道Netbeans的,但如果你做同樣的在Eclipse中,您必須指定主類,以明確(即使只是有一個項目包含水管─執行方法),如果你想要Jar可以通過java -jar或其他方式執行(雙擊它等)。我想你也必須在Netbeans中這樣做,並且你忘記了這一點。

使用谷歌搜索netbeans export jar executable(最後一個字出現的建議)結果包含Netbeans Knowledge Base Article其中的步驟描述。

您引用的警告與您的問題無關。我敢肯定,如果你谷歌的消息,將有大量的描述它的意思已經;-)