Question:
I created a short Text adventure in java, and saved it as a .jar file, but it won t open?
Cameron
2015-07-25 19:54:59 UTC
i am new to coding and I just finished some basics for Java coding, and decided to make a short text adventure game. I saved it as a .jar file, but whenever I go to open it, it says that the file is either invalid or corrupt,can someone please tell me how to fix this
Three answers:
husoski
2015-07-25 20:08:09 UTC
You don't "save it as a .jar file", so that makes me think you didn't create the JAR properly. You use the JAR utility to create a JAR file from your compiled .class files. You also need a manifest to specify the main class when the JAR is used to run a program rather than as an extra run-time library.



The official Java Tutorials site at oracle.com has a trail on this if you're working from the command line:

http://docs.oracle.com/javase/tutorial/deployment/jar/index.html



If you use an IDE like NetBeans or Eclipse, all Java executables are automatically packaged as JAR files during the build process.
?
2015-07-26 08:09:55 UTC
Recheck your code and rewrite correctly. You cant make this game just by changing format. You need to runit through an IDE or some package bundle.
Tony
2015-07-25 19:56:11 UTC
Hmm. Try right clicking your game, going to properties, and running it in Windows XP mode. If that doesn't work, it's most likely an issue with your code.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...