【发布时间】:2013-01-17 18:27:18
【问题描述】:
我已经在一些游戏代码上工作了几个小时,之前它运行得非常好,但后来我的 eclipse 决定破坏一些东西,我完全恢复它并且它在 eclipse 中完美运行,但是当我尝试运行它时CMD 或只是作为可执行 JAR 我得到无法找到或加载主类错误。这是我目前的主要方法。
public Game() {
setMinimumSize(new Dimension(WIDTH * 2, HEIGHT * 2));
setMaximumSize(new Dimension(WIDTH * 2, HEIGHT * 2));
setPreferredSize(new Dimension(WIDTH * 2, HEIGHT * 2));
frame = new JFrame(NAME);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(this, BorderLayout.CENTER);
frame.pack();
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setIconImage(Icon);
}
private boolean running = false;
public InputHandler Inputs = new InputHandler(this);
public static void main(String[] args) {
System.out.println("Starting");
Game g = new Game();
g.Start();
}
public void Start() {
running = true;
new Thread(this).start();
}
private static final int MapHeight = 40;
public void Stop() {
running = false;
}
我使用的是 Windows 7 和 JAVA 7。 希望我能得到一些帮助。
【问题讨论】:
-
你在manifest文件中设置了主类吗?
标签: java