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*


Where,

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" %*
pause

Posted

in

by

Tags:


Related Posts

Comments

4 responses to “Create Executable jar file of classes in package”

  1. […] article, How to create executable jar file for packages in java Sharevar dzone_url = […]

  2. javin @ loop map in java Avatar
    javin @ loop map in java

    great tutorial,Its more easy if you use IDE like Eclipse or netbeans. by the way I have also shared some tips around how to create executable jar in java and how to view contents of jar file. you may find interesting.

  3. mountainb Avatar

    Thanks again. I just changed some of the back slashes to forward ones to run on Ubuntu 12.04
    Javac 1.7.0_03, Great tutorial. b

  4. Abhi Avatar
    Abhi

    ku

Leave a Reply

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

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading