---
title: "Java: JAR file"
date: 2015-01-03
description: "JAR is like Zip but for Java files. A JAR file simply contains a bunch of Java files and resources. ## Extract a JAR Open Terminal and type this, changing..."
canonical_url: https://idratherbewriting.com/java-jar-file/
---
# Java: JAR file
JAR is like Zip but for Java files. A JAR file simply contains a bunch of Java files and resources.

## Extract a JAR

Open Terminal and type this, changing sample.jar to your jar file’s name:

## Export to JAR

In Eclipse, got to **File > Export > Java > Jar**.

If you’re trying to share source files, include the following option in the export settings: “Export Java source files and resources”.

If you’re exporting your code for someone to use, just export the class files.

## Adding a JAR file directly in Eclipse

If you receive a JAR file from someone, you can add the JAR file directly into your Eclipse project. Eclipse will then give you access to the classes without requiring you to extract them from the JAR.

Here’s how you add the JAR to a project in Eclipse. After you create a Java project, create a new folder by going to **File > New > Folder**. Call it “lib”. Then import the JAR file into the lib folder by going to **File > Import > General > File**. Alternatively, you could just copy the JAR file manually into that folder by navigating to it in your workspace.