Using Java jar files. This tutorial explains the usage and purpose of Java JAR files.
A Java library contains code which you can access and use in your Java project. The deployment format of a Java library is a JAR file.
A JAR file is a Java archive based on the pkzip file format. JAR files are the deployment format for Java. A JAR can contain Java classes and other resources (icons, property files, etc.) and can be executable.
You can distribute your program in a jar file or you can use existing java code via jars by putting them into your classpath.
If you add a JAR file to your classpath, you can use its classes in your Java application.
An executable JAR means the end-user can run the Java application without explicitly specifying the Java class which should be started.
This is done via a
MANIFEST.MF file which tells the JVM among other things which class contains the
main() method and the classpath.
The following example shows one possible
Manifest-Version: 1.0 Main-Class: com.vogella.example.MyApp Class-Path:. lib/jcommon-1.0.6.jar lib/itext-1.4.6.jar
An empty line is required at the end of the
You can create an executable JAR file via the following command.
jar -cvmf MANIFEST.MF app1.jar *.class
Eclipse provides an export wizard to create a JAR file which can be started via.
|TRAINING||SERVICE & SUPPORT|
The vogella company provides comprehensive training and education services from experts in the areas of Eclipse RCP, Android, Git, Java, Gradle and Spring. We offer both public and inhouse training. Whichever course you decide to take, you are guaranteed to experience what many before you refer to as “The best IT class I have ever attended”.
The vogella company offers expert consulting services, development support and coaching. Our customers range from Fortune 100 corporations to individual developers.
Copyright © 2012-2016 vogella GmbH. Free use of the software examples is granted under the terms of the EPL License. This tutorial is published under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Germany license.