Showing posts with label JARs. Show all posts
Showing posts with label JARs. Show all posts

Thursday, 25 April 2013

Signing Jar Files with the "JJA" Sequence

Jar files can be signed using the following syntax [henceforth referred to as the "JJA" sequence]:

jarsigner jar-file alias

The alias identifies the private key used to sign the Jar file, and the key's associated certificate. Quite interesting how that alias works....it's a lookup into the Keystore, where each private and public key pair is identified by an alias, and a password is needed to access the private key. The keystore is generated by the Keytool.

Thursday, 11 June 2009

"Linking" to Third Party Jars in Eclipse (the Correct Way using Java Build Path)

How

Select Project->Properties in Eclipse.

Alt-P (Project Menu) -> Pause -> P (Properties)

Select "Java Build Path" from section on left. Choose "Libraries" tab and "Add External Jars".

Does it make sense to talk about "linking" to a jar

We are just referencing code, but then again, isn't that what linking is.

Creating Jars in Eclipse

Frequently we may wish to build an open-source Java library and export it as a JAR. Asssuming we have created a new workspace in Eclipse, e.g. Apache Commons, composed of multiple projects e.g. Lang (which we have imported into Package Explorer using "Create Java Project from Existing Ant Build File") we can create a JAR for the Lang project as follows:

1. Right click on Project in Package Explorer
2. Select Export..
3. Select Java/JAR file
4. Enter a name for the file e.g. project name and version number, like commons-lang-2.4.jar

Once the JAR is built (by default it will be in the directory for the current workspace), you can inspect the file as follows:

jar -tvf commons-lang-2.4.jar | grep class | wc -l

will return a count of 127 class files.

Sunday, 10 May 2009

Creating Executable Jar Files

Java 1.2 brought with it the ability to create executable jar files. You can do this from eclipse using "Jar Export" wizard.

Thursday, 7 August 2008

Semantics of java -jar

When we run jar files we can do so using java -jar. But what are the implications of this on classpath etc.?

The JAR (Java ARchive) file will contain a Manifest stating where the main method is located. JAR files provide compression for efficient storage.