What is a JAR file
A JAR file (Java Archive), is an archive based on the ZIP format. JAR files are therefore identical to ZIP files, but are around a folder META-INF which provides the interpreter with further information about the JAR file.
JAR files are used to summarize the individual files in a project. In addition to class files, multimedia content (images, sound, etc.) can often be found in an archive.
We therefore differentiate between JAR files in Java applications and Java libraries, which in turn add functions to Java applications.
If a JAR file contains a META-INF directory with a manifest file with an entry for a start class (main class), the JAR file can be started with a click of the mouse with a suitable JRE.
The META-INF folder always contains a MANIFEST.MF file, in which information about the archive or the program is described.
When a JAR file is signed, a signature file is automatically generated and stored in the META-INF directory of the JAR file, which also contains the archive's manifest. Signature files have filenames with the extension .SF. In addition, a signature block file with the file extension .DSA.
The minimum execution of a manifest file looks like this:Manifest version: 1.0 Main-Class: HelloWorld [LEERZEILE]
Various properties are described in the manifest file. The properties are specified by a tuple of keyword and value. Different properties are also provided for different areas of use:
|Generally||Manifest version||Version number for the manifest file||No|
|Created-By||Optional specification of the creator||Yes|
|Surname||Specification of the name of a file, e.g. for a signature or bean||Yes|
|SHA1 digest||SHA1 signature for the file specified above||Yes|
|Signature version||Defines the version of the signature||Yes|
|Class path||Specification of classes and JAR files to be added to the classpath; they should always be specified with ./ beginning||Yes|
|Permissions||Since Java 7 Update 51, the permissions must be specified. Valid are (no extension of rights required) and (e.g. for read / write rights). (More on this under Permissions)||No (only for applets and WebStart)|
|Application name||The name of the application must be specified here. (More on this under application name)||No (only for applets and WebStart)|
|Codebase||The source domain, i.e. the place of origin, must be specified here. (More on this under Codebase)||No (only for applets and WebStart)|
|Applications||Main class||Specification of the main class, it is necessary if the JAR file is to be executable||Yes (if it's not an executable program)|
|SplashScreen image||Specification of an image to be displayed as a splash screen. The image must be in the JAR.||Yes|
|* Extension name|
|* Specification version|
|* Implementation version|
|* Implementation url|
|Implementation Vendor ID|
|J2EE||Java bean||Defines a Java Bean class|
Each manifest file must end with a blank line.
Example of a manifest fileManifest-Version: 1.0 Created-By: Eagle Projekt Manager 22.214.171.124 Permissions: all-permissions Codebase: * .eagleside.de Application-Name: DatabaseDesigner Main-Class: de.eagleside.databasedesigner.DatabaseDesignerMain CLASS-PATH: ./lib /jdom.jar ./lib/EagleSwingLibrary.jar ./lib/EagleUtilLibrary.jar [blank line!]
It is common to put dependencies in a subdirectory relative to the program jar file. Drive specifications are system-dependent, so they should not be used.
To create a JAR file from a fully compiled project on a command line, the following command must be used:jar cvfm MeinJar.jar manifest.txt input-file (s)
The input file (s) is a list of one or more files that the jar file should contain. Multiple files are separated from each other with a space. Several files of the same type can be specified with a wildcard symbol (*). If an item to be saved is a directory, the contents of that directory are recursively added to the jar file.
Accordingly, the following command is valid for creating a jar file:jar cvfm MeinJar.jar manifest.txt icons audio * .class license.txt
A manifest is added to the jar file. It will also contain directories with icons and audio files (icons, audio) in which the program icons and some sound files have been stored. Finally all the class files and a license file. Most of the available IDEs already have functions on board that can be done conveniently with a click of the mouse.
In order to start the program execution of a Java application that is saved in a JAR file by double-clicking, it is necessary that the file extension (.jar) is linked to the Java interpreter. Usually this is the case with Windows systems. With Linux systems you often have to help out.Tip: You can find out how to proceed if a jar file does not start in the article Jar file cannot be executed with double-click.
In addition to the start with a mouse click, the start in the command line is particularly important in order to be able to read exceptions that are thrown in the Java console during execution. The following command starts the execution of an application saved in a JAR file:java -jar MyJar.jar
The topic was not dealt with adequately? Do you have any questions about this and need more information? Let us help you!
We are happy to help you!
Did you like this article? Or have you discovered errors and would like to contribute to the correction? Great! Write a comment!
You must be logged in to leave a comment.
- What is an electric fish tape
- Can you play monopoly yourself
- Psychopaths start doing something subconsciously
- What does procedure mean in computer language
- Why is salt added to sweet things?
- What is CLAT advice
- How many types of motor windings
- Can a person be too goal oriented
- An iPhone 6s plus can charge itself
- Do stuffed animals have feelings
- How did Roman art affect the world?
- When is contemporary art no longer appropriate?
- Can one call Varanasi an international city?
- How can I calculate the goodwill
- Who would win Meliodas or Incursio Tatsumi?
- Has capitalism encouraged false altruism?
- Who will be coming Akshay Kumar
- How do I become a joyful person
- Is it really worth giving someone a gift
- Can Quora be marked as NEEDED UPGRADE
- Politics should be a job
- Can LTE be changed to Volte
- Has capitalism encouraged false altruism?
- Why doesn't Quora just show new answers
- Why aren't endorphins addicting?
- Where in Austin TX is Graffiti Park
- Why does my water smell like mold
- What do you think of Mars One
- Has Spain become a socialist nation?
- How do I remove a PVC connection
- How we can analyze a signature
- Why are gmos bad
- How many people work at Google DeepMind