简体   繁体   中英

Exported eclipse runnable .jar will not run

So i'm pretty new to programming and java and I finished a Prime number program. It runs in the cmd and doesn't use any GUI. When I try to double click it the cmd window pops up for like a frame then disappears. When I try to run it with the command "java -jar _____.jar" it works fine and it works fine in eclipse. Earlier I was getting an error saying that I don't have a main manifest attribute but it seemed to go away. If you guys know the fix to the main attribute thing I could try that. Other than that anyone have any ideas?

Here's a link to a previous similar question. They have some good solutions there.

A simple one to try starting out is JarFix which will re-associate .jar files with the right java exe.

If your program is immediately closing upon running, try adding snippet at the end of it to keep the process alive.

System.out.println("Press enter to close.");
try {
    System.in.read();
} catch (Exception e) {
    e.printStackTrace();
}

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