(Source Code) Running an executable JAR from command-line
Source Code : Running an executable JAR from command-line
An “executable JAR” is nothing but a JAR in which the entry point of execution is defined. That definition can be given in its manifest file (META-INF/Manifest.mf).
The general structure of a JAR file:
+-MyJar.jar
|-+-META-INF
|-|—-Manifest.mf
|-+-com
|-|-+-package
|-|-|—-MyJavaFile.java
|-|-|—-MySecondJavaFile.java
The manifest file should contain the details of the JAR file. It keeps the attribute as key-value pairs.
The structure of a manifest file:
Main-Class: com.package.MyJavaFile
Specification-Title: "Java Utility Classes"
Specification-Version: "1.2"
Specification-Vendor: "Sun Microsystems, Inc."
Implementation-Title: "java.util"
Implementation-Version: "build57"
Implementation-Vendor: "Sun Microsystems, Inc."
If the executable JAR is dependent on any other JAR, we need to specify it in the Manifest itself (even though there is an option to do it while invoking the application thru java -cp).
Courtesy:- Javabeanz.wordpress.com
- guru's blog
- Login to post comments
