Java JAR Command
Creating a JAR
The following creates a jar file and sets the entry point in Manifest.txt
:
jar cfe my-app.jar package1.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 my-app.jar <arg0> <arg1> .. <argN>
No Comments