Metawerx Java Hosting Small Logo

JAR file

A Java Archive file.

JAR files are basically just zip archive files with a .jar extension, and contain Java classes in a directory structure, and a META-INF folder, containing some information about the archive.

They are used to package a set of similar classes in a single file.

For example, if you download the Java Mail API, it will come as a jar file. To use it, you would install it into your WEB-INF/lib folder, making the classes available for use in your application.

Looking inside a JAR file

To open a JAR file and have a look inside, rename it as a .zip file, and then open it as you would any other zip file.

Where are JAR files installed?

JAR files used by a single web application are installed in the WEB-INF/lib folder of the application.

JAR files available to the entire JVM are installed in the JVM classpath. The rt.jar file in the JDK folder contains the Java Runtime classes.

In Tomcat, the <jakarta>/common/lib folder contains JAR files which are included in the classpath for all applications running in that Tomcat instance. Therefore, if you install common JAR files in this location, they become available to all applications.

metawerx specific

referring pages