JAR
Definication
JAR are built on theZIP
format and typically have a .jar file extension.(come from zip)
A JAR (Java Archive) is a package file format typically used to aggregate many Java class files and associated metadata and resources (text, images, etc.) into one file for distribution.
JAR files are archive files with which include a Java-specific manifest file.Extraction
The contents of a JAR file may be extracted using any standard decompression software(zip command etc.), or the jar command line utility: “jar -xf foo.jar”.
1 | unzip foo.jar |
- Executable JAR files
An executable Java program can be packaged in a JAR file, along with any libraries the program uses.
Executable JAR files have the manifest specifying the entry point class with Main-Class: myPrograms.MyClass and an explicit Class-Path (and the -cp argument is ignored). Some operating systems can run these directly when clicked. The typical invocation is java -jar foo.jar from a command line.
1 | #./META_INF/MANIFEST.MF |
Execute Jar file1
java -Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m -XX:MaxMetaspaceSize=256m -jar /path/to/jarfile.jar
WAR
Definication
In software engineering, a WAR file (or Web application ARchive)is a JAR file
used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XML files, tag libraries, static web pages (HTML and related files) and other resources that together constitute a web application. (come from jar file)Extraction
Same with jar file.
1 | unzip foo.war |
- Executable WAR files
use Tomcat
Genarate jar/war/zip to deploy
Maven project can generate jar/war simply by setting pom.xml
1 | <packaging>jar</packaging> |
Genarate
1 | mvn package |
Play framework use dist command generate zip file, or use sbt-assembly plugin to generate jar file.
1 | sbt dist |