How to create jar in mac

By | April 28, 2015

How to create jar in mac

Steps to create a jar in mac and run it are as below :

1. Create a folder named jar

2. Place your .java and .class files in it (if you don’t have the class file then go to this directory and compile your java file and that will create a class file for you – javac Hello.java)

3. Open the terminal app and navigate to the directory jar where you created it

4. Create a manifest file

Open textEdit and write the following in it:

Main-Class : Hello

That means your class name and the file should end with a new line character that means press enter at the end.

Save this file as Manifest.txt and place it in your jar folder

5. Run terminal command : jar cfm Hello.jar Manifest.txt Hello.class

6. Now run your jar using : java -jar Hello.jar