- In
the Package Explorer, we can optionally pre-select one or more Java
elements to export. These will be open the wizard page.
- Either
from the context menu or from the menu bar's File menu, select Export.
- Expand
the Java node in the wizard page and select JAR file. Click Next.
- In
the JAR File Specification page, select the resources that we want to
export in the Select the resources to export field.
- Select
the appropriate checkbox to specify whether we want to Export generated
class files and resources or Export Java source files and resources. Note:
Selected resources are exported in both cases.
- In
the Select the export destination field, either type or
click Browse to select a location for the JAR file.
- Select
or clear the Compress the contents of the JAR file checkbox.
- Select
or clear the Overwrite existing files without warning checkbox. If we
clear this checkbox, then we will be prompted to confirm the
replacement of each file that will be overwritten.
- Note:
The overwrite option is applied when writing the JAR file, the JAR
description, and the manifest file.
- Now
we have two options:
- Click Finish
to create the JAR file immediately.
- Click Next
to use the JAR Packaging Options page to set advanced options, create a
JAR description, or change the default manifest.
- If
we want to save the JAR file description, select the Save the description
of this JAR in the workspace checkbox. A JAR file description can be used
to regenerate a JAR file without using the wizard.
- The
compiler is able to generate CLASS files even when source contains errors.
We have the option to exclude CLASS (but not source) files with compile
errors. These files will be reported at the end, if reporting is enabled.
- We
can choose to exclude CLASS (but not source) files that have compile
warnings. These files will be reported at the end.
Note: This option does not automatically exclude class files with compile errors. - We
can choose to include the source folder path by selecting the Create
source folder structure checkbox.
- Select the Build projects if not built
automatically checkbox if you want the export to perform a build before
creating the JAR file.
- Click
Finish to create the JAR file immediately or Next if we want to change the default manifest.
- If
it is not already selected, click the Generate the manifest file
button.
- We
can now choose to save the manifest in the workbench. This will save the
manifest for later use. Click Save the manifest in the workspace,
then click Browse next to the Manifest file field to specify a
path and file name for the manifest.
- If
we decided to save the manifest file in the previous step and you chose to
save the JAR description on the previous wizard page, then you can choose
to reuse it in the JAR description (by selecting the Reuse and save the
manifest in the workspace checkbox). This means that the saved file will
be used when the JAR file is recreated from the JAR description.This
option is useful if you want to modify or replace the manifest file before
recreating the JAR file from the description.
- We
can choose to seal the JAR and optionally exclude some packages from being
sealed or specify a list with sealed packages. By default, nothing is
sealed.
- Click
the Browse button next to the Main class field to specify the
entry point for our applications.
Note: If our class is not in the list, then we forgot to select it at the beginning. Click Finish. This will create the JAR, and optionally a JAR description and a manifest file.
Wednesday, 4 July 2012
To create a JAR file in the Eclipse workbench
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment