[英]jar made in Neatbeans doesnt work
已經研究了許多幫助條目,但沒有一個幫助我。 我是 java/netbeans 的新手,我認為我的問題的答案很簡單(至少我希望如此)。 我在 NetBeans 中運行我的項目沒有任何困難,但是當我“清理並構建項目”並嘗試打開 jar 時沒有任何反應。 也用cmd嘗試過:
java -jar mapomizer.jar
構建項目時只有一個警告:
警告:[options] 引導類路徑未與 -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);
}
});
}
}
我不知道 Netbeans 但如果你在 Eclipse 中做同樣的事情你必須指定要顯式執行的主類(即使項目中只有一個包含主方法)如果你想讓 Jar 被java -jar
或其他方式(雙擊它等)。 我想您也必須在 Netbeans 中這樣做,而您忘記了這一點。
谷歌搜索netbeans export jar executable
(最后一個詞作為建議出現)結果包含描述步驟的Netbeans 知識庫文章。
您引用的警告與您的問題無關。 我敢肯定,如果您在 google 上搜索該消息,就會有很多說明已經是什么意思了 ;-)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.