0

So, I have a game I made with Java and Netbeans. It's finished, and runs with no errors in Netbeans. Clean and build returns no errors either, and I have my little .jar file in the dist folder. However, when I attempted to run(double-click) the jar file, nothing happened. Then I tried it in the command line, and I got a AWT-Event Queue 0 Error pointing to a variable declaration (no foreseeable bug, but not in the main class). Since I have no errors while running in Netbeans, I'm assuming the compiled code is screwed up. The question is, why, and how do I fix it. There is a "lib" folder inside the dist folder containing an imported class (inside the code), and my program relies on images in the project file.

Jimmt
  • 852
  • 2
  • 11
  • 29

2 Answers2

0

You may have some variables that have not been initialized or not instantiated.

You need to review your codes then re-compiled it.

example:

JButton myButton = new JButton("Button");
  • So simply leaving a variable like JButton button; in the main class, without instantiating it, is unacceptable? Why would it be like that? – Jimmt Apr 01 '12 at 18:42
0

What was the error message / stack trace you got?

It could be that the program can't find your library. Make sure to execute the jar from the same folder than contains the lib folder. That, or tell netbeans to package the library inside the jar (I forget how to do this).

The other problem might be how you access files. You need to access the files via the base class loader, otherwise the file path will be pointing to different locations when run normally, and when run as a jar. This question might help you.

Community
  • 1
  • 1
Dunes
  • 37,291
  • 7
  • 81
  • 97