jar

To make a jar file on Mac just first need to open up the Terminal window.
1. Go to the directory of where your java file is by entering

cd myDirectory

2. Compile your java file(myJava.java) into a class

javac myJava.java

List the content of the directory to make your the class file has been made

ls -l

3. To indicate which function to run first in the jar file we will need to create a text file (MainClass.txt) with the content in the same directory as the java file:

Main-Class: myJava

4. The last command to create the actual jar file looks like this:

jar cmf MainClass.txt myJava.jar *.class

5. Run your jar file! You can run it by clicking on it or by entering the follwoing command in the Terminal window

java -jar myJava.jar