Java i18n Internationalization Example

Internationalization is the process of designing an application so that it can be adapted to various languages and regions without engineering changes.

Sometimes I was wondering term internationalization is abbreviated as i18n, Why? and Found reason is   there are 18 letters between the first "i" and the last "n." :)

Why to use i18n and Benifits of i18n :
  1. Support for new languages does not require recompilation as stored in Properties Files.
  2. Can be localized quicklyby setting Local as per Language and country
  3. Instead of hard coding Textual elemtns(GUI labels,status message,Error message. they are stored outside and retrieved dynamically.
  4. By small additional of data(properties file of different landuage) , same code can be run WorldWide.
  5. Culturally dependent data, like dates and currencies, appear in formats that line up with user's region and language

Viewing Content of Jar in Java

jar tvf <myjarfile>.jar - Display Verbose output

0 Mon Mar 28 01:49:30 IST 2011 META-INF/
 217 Mon Mar 28 01:49:28 IST 2011 META-INF/MANIFEST.MF
   0 Mon Mar 28 01:49:30 IST 2011 datamapping/
   0 Mon Mar 28 01:49:30 IST 2011 datamapping/Properties/
  777 Mon Mar 28 01:49:28 IST 2011 datamapping/DataMapping$1.class
  770 Mon Mar 28 01:49:28 IST 2011 datamapping/DataMapping$2.class
  553 Mon Mar 28 01:49:28 IST 2011 datamapping/DataMapping$3.class
16453 Mon Mar 28 01:49:28 IST 2011 datamapping/DataMapping.class
  553 Mon Mar 28 01:49:30 IST 2011 datamapping/DisplayData$1.class
 2331 Mon Mar 28 01:49:30 IST 2011 datamapping/DisplayData.class
 4938 Mon Mar 28 01:49:30 IST 2011 datamapping/Properties/Envproperties.properties

jar tf <myjarfile>.jar - This command displays the contents of the JAR file to stdout:

How to Create Jar in Java

jar cf  <jar-file>  <input-files>

Options :
c  - option indicates that you want to create a JAR file.

- option indicates that you want the output to go to a file rather than to stdout.

jar-file  - is the name that you want the resulting JAR file to have. You can use any filename for a JAR file. By convention, JAR filenames are given a .jar extension, though this is not required.

input-file(s) - is a space-separated list of one or more files that you want to be placed in your JAR file.
If any of the "input-files" are directories, the contents of those directories are added to the JAR archive recursively.

How to List Entries in Jar Files using Java Program

The JarFile class is used to read the contents of a JAR file.

Class JarFiles extends the class java.util.zip.ZipFile with support for reading an optional Manifest entry. The Manifest can be used to specify meta-information about the JAR file and its entries.

JarFiles has method called entries() which is used to returns an enumeration of the ZIP file entries. Using Enumeration, You can iterate over entries to list enteries in JarFiles