Java JAR Command
Creating a JAR
The following creates a jar file and sets the entry point in Manifest.txt
:
jar cfe <compiled>.jar <package>.<MainClass> <package1>/*.class <package2>/*.class
Reference: https://docs.oracle.com/javase/tutorial/deployment/jar/appman.html
Be sure you are in the correct classpath directory (above your package directory). This is the same directory level where you can compile .java
files and execute .class
files:
javac package1/MyClass.java
java package1.MyClass <arg0> <arg1> .. <argN>
Executing a JAR
The following command executes a compiled JAR file:
java -jar <compiled>.jar <arg0> <arg1> .. <argN>