Create Executable jar file of classes in package

For the source code, please refer this article.

As per previous article, i am considering that you have already compiled the program.

go to the folder “classes” and create a manifest file named as “manifest.txt” and add the name of starting java class as shown below.

Main-Class: com.g2.ExecJar.Start

or, run below command in command prompt

echo Main-Class: com.g2.ExecJar.Start >manifest.txt

now, run the command to create a jar file:

jar cvfm First.jar manifest.txt comg2ExecJar*


To run the jar, in command prompt, enter command:

java -jar First.jar

Question :Why the jar file is not executing ? it opens in winrar instead of execution.
Answer :
This problem occurs mainly after installation of the winrar. To change the program for opening jar file, run below code in batch file:

@echo OFF
assoc .jar=jarfile
ftype jarfile="D:RMBjdkbinjavaw.exe" -jar "%1" %*


Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.