This article will show you how to create a Java archive, specifically a JAR file, using the free Java program Eclipse. This can be done on a Windows computer and Mac OS X.
Part 1 of 2: How to install the Eclipse program
Step 1. Make sure you have the Java Development Kit (JDK) installed
If there is no JDK on your computer, download and install it.
Step 2. Open the Eclipse website
If Eclipse is already installed, go to the next section
Step 3. Click on DOWNLOAD
It's a button at the top of the page.
Step 4. Click on DOWNLOAD
This orange button is at the top of the page that opens. Eclipse starts downloading to your computer.
Step 5. Wait until the download is complete
This will take some time.
Step 6. Run the Eclipse installer
- On Windows double click on the downloaded file and then click “Yes” when prompted.
- On Mac OS X double click on the downloaded archive (zip file) and wait for it to unpack.
Step 7. Open the Eclipse Installation Wizard window
To do this, double click on the purple Eclipse icon when it appears.
If you clicked on the “Change Mirror” link under the orange “DOWNLOAD” button, the Eclipse program itself may open. In this case, go to the "Click Browse" step
Step 8. Click Eclipse IDE for Java Developers
It's the top option in the Eclipse Installation Wizard window.
Step 9. Click Install
This yellow button is at the bottom of the window. The installation of Eclipse on your computer begins.
- If you want, specify the folder where the program will be installed; to do this, click the folder-shaped icon to the right of the Installation Folder option, and then select a specific folder on your computer.
- If you do not want to create shortcuts for Eclipse, first uncheck the corresponding options and then click Install.
Step 10. Click Launch
This green button is at the bottom of the setup wizard window. The Eclipse program will open.
Step 11. Click Browse
It's on the right side of the window. An Explorer (Windows) or Finder (Mac OS X) window opens.
Step 12. Select the workspace folder
Click on the desired folder on the left side of the screen. This folder will contain the Eclipse project files.
Step 13. Click on OK
It's in the lower-right corner of the window.
Step 14. Click Launch
You will find this option at the bottom of the window. The Eclipse home page will open.
Part 2 of 2: How to create a JAR file
Step 1. Copy the required files into one folder
The files to be placed in the JAR file must be in the same folder.
Step 2. Click on File
This menu is located in the upper-left corner of the window (Windows) or in the upper-left corner of the screen (Mac OS X). A dropdown menu will open.
Step 3. Click on Open File
It's near the top of the drop-down menu.
Step 4. Open the folder with files
Find the folder with the files you want, and then double-click the folder to open it. A list of files will be displayed on the screen.
Step 5. Select all files in the folder
Click on any file and then press Ctrl + A (Windows) or ⌘ Command + A (Mac OS X) to select all files in the folder.
Step 6. Click Open
It's in the lower-right corner of the window. The files will open in Eclipse.
Step 7. Click on File
A dropdown menu will open.
Step 8. Click Export
It's near the bottom of the drop-down menu.
Step 9. Double click on Java
It's near the top of the page.
Step 10. Click the JAR file
You will find this option under the "Java" option that you double-clicked on.
If you want the JAR file to run as a program, select the Executable JAR File option
Step 11. Click Next
This button is at the bottom of the window.
Step 12. Select assets to export
Check the boxes next to the unchecked resources that you want to add to your JAR file. Do this in the box at the top of the page.
Skip this step if you choose to create an executable JAR file
Step 13. Select a folder to store the JAR file
Click Browse, enter a filename, click the folder where the JAR file will be stored, and then click Save.
Step 14. Click Finish
The JAR file will be generated (it will take some time to compress the files).