Let us say, we have 2 compiled classes Employee and Person inside the folder "ALL" which resides inside the folder "Java". Employee class contains static void main method.
Before creating a Jar file, first create a mainclass file in the Java folder. Specify the name of the class in which main methods resides. Here (“Main-Class: All.Employee”) and press enter.
Open command prompt and navigate to Java Folder. Enter the following command in the command prompt “jar cmf mainclass myfirst.jar All/*.class” and press enter. Executable jar will created. To test the newly created jar, use following command “java -jar myfirst.jar”