简体   繁体   中英

Why when I run my chess project as a runnable jar file I get a strange behavior while when I run it inside eclipse everything works just fine?

One day I have decided to test my java skills by building a simple chess game. It took me some time and after a while I finished it. Now the problem starts here: I wanted to send my friends my game so I created a runnable jar file through Eclipse. Surprisingly the game inside the runnable jar file showed some strange behaviors like Pieces appearing where they shouldn't appear and some other weird bugs, but without any exceptions. I was even more surprised when I realized that when I run the project inside Eclipse itself everything works like it should. I also tried to create a normal jar file through Eclipse and run it, but I got the following NPE error:

01/05/12 19:47:30.433 [0x0-0x54054].com.apple.JarLauncher: Exception in thread "main" 

01/05/12 19:47:30.498 [0x0-0x54054].com.apple.JarLauncher: java.lang.NullPointerException

01/05/12 19:47:30.498 [0x0-0x54054].com.apple.JarLauncher:  at sun.launcher.LauncherHelper.getMainClassFromJar(LauncherHelper.java:399)

01/05/12 19:47:30.498 [0x0-0x54054].com.apple.JarLauncher:  at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:463)

I have already posted one question about this on this website, but I didn't get a proper answer so I am posting also this question. Here is a link to the other question: Getting a strange behavior when creating a runnable jar file on eclipse for my Chess project .

You should have the following manifest header in an executable jar:

Main-Class: classname

You can do this automatically while exporting jar from eclipse, by selecting a main class in the export jar wizard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM