Method 1:
In eclipse, you can export jar files (similar to EXE files, but supported by Java Virtual Machine) and execute file → export → jar (runable.
Eclipse --> right-click a Java project --> export --> JAVA-JAR file/runnable JAR File
// It can also be a package under the project
Method 2:
Jar command:
Example 1: Archive two class files to an archive file named 'classes. jar:
Jar CVF classes. Jar Foo. Class bar. Class
Example 2: use an existing manifest file 'mymanifest'
Archive the file to an archive file named 'classes. jar:
Jar cvfm classes. Jar mymanifest-C Foo /.
Jar usage:Jar {ctxu} [vfm0mi] [Jar-file] [manifest-file] [-C Directory] File Name...
Option:
-C. Create a new archive
-T list the archived content
-X expand the named (or all) files in the archive
-U: update an existing archive
-V generates detailed output to the standard output
-F specifies the archive file name
-M contains the marker information from the specified file.
-0 storage only; zip compression format not used
-M does not generate a manifest file for all items
-I generates index information for the specified JAR File
-C changes to the specified directory and contains the following files:
If a file name is a directory, it is recursively processed.
Both the configuration (manifest) file name and the archive file name must be specified, in the same order specified by the 'M' and 'F' signs.