How to run a JAR file

I created a JAR file like this:

jar cf Predit.jar *.*

I ran this JAR file by double clicking on it (it didn’t work). So I ran it from the DOS prompt like this:

java -jar Predit.jar

It raised “Failed to load main class” exceptions. So I extracted this JAR file:

jar -xf Predit.jar

and I ran the class file:

java Predit

It worked well. I do not know why the JAR file did not work. Please tell me the steps to run the JAR file

11 Answers
11

Leave a Comment