[英]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.