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