how to compile java programs into .jar files code example Example 1: compile jar file command jar cvf example.jar * Example 2: compile java to jar in mac javac HelloWorld.java