Home Tutorials Training Consulting Products Books Company Donate Contact us

NOW Hiring

Quick links


Using Java jar files. This tutorial explains the usage and purpose of Java JAR files.

1. Defining and using Java libraries

1.1. What is a Java library?

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.

1.2. What 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.

2. Executable JAR

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.MF file.

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 MANIFEST.MF file.

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 File ▸ Export ▸ Java ▸ JAR file.

Create JAR file with the Eclipse export wizard

3. About this website

4. Links and Literature

Nothing listed.

4.1. vogella GmbH training and consulting 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-2017 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.

See Licence.