Java Cross Platform Benefit: Write Once , Run Anywhere

“Write once, run anywhere” (WORA), or sometimes Write once, run everywhere (WORE), is a slogan created by Sun Microsystems to illustrate the cross-platform benefits of the Java language. Ideally, this means Java can be developed on any device, compiled into a standard bytecode and be expected to run on any device equipped with a Java virtual machine (JVM). The installation of a JVM or Java interpreter on chips, devices or software packages has become an industry standard practice.

This means a programmer can develop code on a PC and can expect it to run on Java enabled cell phones, as well as on routers and mainframes equipped with Java, without any adjustments. This is intended to save software developers the effort of writing a different version of their software for each platform or operating system they intend to deploy on.

The catch is that since there are multiple JVM implementations, on top of a wide variety of different operating systems such as Windows, Linux, Solaris, NetWare, HP-UX, and Mac OS, there can be subtle differences in how a program may execute, which may require an application to be tested on various target platforms. This has given rise to the joke among Java developers, “Write Once, Debug Everywhere”. However, for a developer, the abstraction layer that Java provides is usually more convenient than recompiling software for each combination of operating system and architecture that it should run on and still represents a significant reduction in work when developing and supporting an application on multiple platforms. [From Wikipedia. All text is available under the terms of the GNU Free Documentation License.]

Backporting Tools In Java

Java Backporting Tools are softwares usually written in Java which convert Java classes bytecodes from newer version of the Java Platform to an older one (for example Java 6.0 backported to 1.5).

The following are a few of the Java Backporting Tools available as of this posting.

  • RetroTranslator
  • RetroWeaver
  • Declawer
  • JBossRetro

Retrotranslator one of the backporting tools makes Java applications compatible with Java 1.4, Java 1.3 and other environments. It supports all Java 5.0 language features and a significant part of the Java 5.0 API on both J2SE 1.4 and J2SE 1.3. In other Java environments only the Java 5.0 features that don’t depend on the new API are supported. Retrotranslator employs the ASM bytecode manipulation framework to transform compiled Java classes and the backport of the Java 5.0 concurrency utilities to emulate the Java 5.0 API. [GoTo RetroTranslator Home]

The following features are supported by RetroTranslator:

  • Generics
  • Annotations
  • Reflection on generics and annotations
  • Typesafe enums
  • Autoboxing/unboxing
  • Enhanced for loop
  • Varargs
  • Covariant return types
  • Formatted output
  • Static import
  • Concurrency utilities
  • Collections framework enhancements

Retroweaver is another backporting tool that enables you to take advantage of the new Java 1.5 language features in your source code, while still retaining compatability with 1.4 (and older) virtual machines. Retroweaver operates by transforming Java class files compiled by a 1.5 compiler into class files which can be run on an older virtual machine. [GoTo RetroWeaver Home]

Retroweaver supports most 1.5 features while running on 1.4 including the following features.

  • Generics
  • Extended for loops
  • Static imports
  • Autoboxing/unboxing
  • Varargs
  • Enumerations
  • Annotations