Reputation: 364
These are precisely the steps that took to create executable jar file so that i can run my swing program by double clicking but it gives me an error saying "Invalid or corrupt jar file" Also trying to execute it through command prompt gives me the same error
Step 1:create a .java file which contains my swing code
Step 2:compile the .java file to .class file
Step 3:create jar file using the command jar cf name.jar classname.class
Step 4:open jar file using winrar archiever and modify manifest file by adding Main-class:classname
Step 5:try to execute the jar file
BUT the above steps dont work and i dont understand why?
I tried another thing too
Step 1:create a .java file which contains my swing code
Step 2:compile the .java file to .class file
Step 3:create jar file using the command jar cf name classname.class
Step 4:open jar file using winrar archiever and modify manifest file by adding Main-class:classname
Step 5:try to execute the jar file.In this case i can open my file through command prompt but not by double clicking. I tried to select javaw option through Open with option but it doesn't give any ouput(not even error)
Upvotes: 0
Views: 2119
Reputation: 755
You can try:
java -cp name.jar Classname
and check for errors at the command prompt.
If your program requires some external libraries, you can mention them inside the manifest file.
Class-Path: lib/file1.jar lib/file2.jar
where lib
is in the same directory where the jar file is.
Upvotes: 2