Home > Java > javaTutorial > How to Include External Libraries in Exported JARs Using Eclipse?

How to Include External Libraries in Exported JARs Using Eclipse?

Susan Sarandon
Release: 2024-12-05 16:00:18
Original
520 people have browsed it

How to Include External Libraries in Exported JARs Using Eclipse?

Including External Libraries in Exported JARs Using Eclipse

When developing a Java project that relies on external libraries, exporting the project as a JAR (Java Archive) often requires including these dependencies for proper execution. In Eclipse, there are two main approaches to accomplish this:

Exporting as a Runnable JAR

  1. Right-click on the project in the Package Explorer.
  2. Select "Export..." from the context menu.
  3. Choose "Runnable JAR File" as the export type.
  4. In the "Runnable JAR File" dialog, go to the "Libraries" tab.
  5. Select the option "Package required libraries into generated JAR".
  6. This option will automatically include all dependencies found in the build path.
  7. Click "Finish" to export the JAR.

Exporting as a Regular JAR

  1. Right-click on the project in the Package Explorer.
  2. Select "Export..." from the context menu.
  3. Choose "JAR File" as the export type.
  4. In the "JAR File" dialog, go to the "Libraries" tab.
  5. If the desired external libraries are present in the project folder, they can be included by checking the corresponding checkboxes.
  6. However, external dependencies such as those managed by Maven cannot be included in this way.
  7. Click "Finish" to export the JAR.

Notes

  • When exporting a runnable JAR, the "Launch Configuration" dropdown will allow you to specify the main class to use when executing the JAR.
  • External dependencies downloaded through Maven or other build tools may require additional configuration to be exposed to the JAR.

The above is the detailed content of How to Include External Libraries in Exported JARs Using Eclipse?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template