You use the JAR Signing and Verification Tool to sign JAR files and time stamp the signature. You invoke the JAR Signing and Verification Tool by using the jarsigner command, so we'll refer to it as 'Jarsigner' for short.
To sign a JAR file, you must first have a private key. Private keys and their associated public-key certificates are stored in password-protected databases called keystores. A keystore can hold the keys of many potential signers. Each key in the keystore can be identified by an alias which is typically the name of the signer who owns the key. The key belonging to Rita Jones might have the alias 'rita', for example.
The basic form of the command for signing a JAR file is
In this command:
First create a key-pair using keytool. Keytool -genkey -alias somekeyname Then use jarsigner to sign it with the key you just created. Jarsigner /path/to/jar somekeyname Note, you need to use the same alias (somekeyname here) as the one you create the key with. Based on the instructions from the Eclipse documentation. To create a new JAR file in the workbench: Either from the context menu or from the menu bar's File menu, select Export. Expand the Java node and select JAR file. In the JAR File Specification page, select the resources that you want to export in the Select the resources to export field. The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 350 open source projects, including runtimes, tools and frameworks. You do not need to extract the private key from Java Card to generate a Certificate Signing Request. Just need to include the public key in the CSR and sign it with the private key. Here Certificate enrollment process you can see the general process explained and the involved code for an Android device. In your case the process could be like this. Jun 19, 2008 Select 'Generate the manifest file' At the bottom, browse for the 'Main class' (it shows only those classes with a main method) Finish; Long answer with command line tools if you want to sort of understand how this works: The first warning sign is that you used.class at the end of the jar create. You need to define Susan Jones when you generate the keys. Put Java class files comprising your application into a JAR file; Sign the JAR file; Export the public key certificate corresponding to the private key used to sign the JAR file; Here are the steps to grant permissions to an application. Note: For convenience, you pretend to be a user.

The Jarsigner tool will prompt you for the passwords for the keystore and alias.
This basic form of the command assumes that the keystore to be used is in a file named .keystore in your home directory. It will create signature and signature block files with names x.SF and x.DSA respectively, where x is the first eight letters of the alias, all converted to upper case. This basic command will overwrite the original JAR file with the signed JAR file.
In practice, you might want to use one or more of the command options that are available. For example, time stamping the signature is encouraged so that any tool used to deploy your application can verify that the certificate used to sign the JAR file was valid at the time that the file was signed. A warning is issued by the Jarsigner tool if a time stamp is not included.
Options precede the jar-file pathname. The following table describes the options that are available:
| Option | Description |
|---|---|
| -keystoreurl | Specifies a keystore to be used if you don't want to use the .keystore default database. |
| -sigfilefile | Specifies the base name for the .SF and .DSA files if you don't want the base name to be taken from your alias. file must be composed only of upper case letters (A-Z), numerals (0-9), hyphen (-), and underscore (_). |
| -signedjarfile | Specifies the name of the signed JAR file to be generated if you don't want the original unsigned file to be overwritten with the signed file. |
| -tsaurl | Generates a time stamp for the signature using the Time Stamping Authority (TSA) identified by the URL. |
| -tsacertalias | Generates a time stamp for the signature using the TSA's public key certificate identified by alias. |
| -altsignerclass | Indicates that an alternative signing mechanism be used to time stamp the signature. The fully-qualified class name identifies the class used. |
| -altsignerpathclasspathlist | Provides the path to the class identified by the altsigner option and any JAR files that the class depends on. |
Let's look at a couple of examples of signing a JAR file with the Jarsigner tool. In these examples, we will assume the following:
http://tsa.url.example.com.Under these assumptions, you could use this command to sign a JAR file named app.jar:
You will be prompted to enter the passwords for both the keystore and your alias. Because this command doesn't make use of the -sigfile option, the .SF and .DSA files it creates would be named JOHNDOE.SF and JOHNDOE.DSA. Because the command doesn't use the -signedjar option, the resulting signed file will overwrite the original version of app.jar.
Let's look at what would happen if you used a different combination of options:
The signature and signature block files would be named SIG.SF and SIG.DSA, respectively, and the signed JAR file SignedApp.jar would be placed in the current directory. The original unsigned JAR file would remain unchanged. Also, the signature would be time stamped with the TSA's public key certificate identified as testalias.
Complete reference pages for the JAR Signing and Verification Tool are on-line: Summary of Security Tools
The Jar File wizard can be used to export the content of a project into a jar file. To bring up the Jar File wizard −
In the Package Explorer select the items that you want to export. If you want to export all the classes and resources in the project just select the project.
Click on the File menu and select Export.
In the filter text box of the first page of the export wizard type in JAR
.
Under the Java category select JAR file.
Click on Next.
In the JAR File Specification page −
Enter the JAR file name and folder.
The default is to export only the classes. To export the source code also, click on the Export Java source files and resources
check box.
Click on Next to change the JAR packaging options.
Click on Next to change the JAR Manifest specification.
Click on Finish.