Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Saturday, November 22, 2008

Running Java 5 Compiled classes/Jar on JRE1.4

Most of you might not need and bother to know about running Java 1.5 compiled classes on JRE1.4. Why? you don't need to. Run with JRE1.5 or higher. No issues.

But sometimes, though i admit it is very annoying that you need to run in that behaviour. You might happen to have a set of codes which relies on an 3rd part API that is Java 5 onwards compatible (i.e. Apache Camel) and it's working great and *SNAP* there's 1 client that still running on JRE1.4 that need to have that functionalities. I've panicked for about 5mins myself until i came across this "Retrotranslator".

Retrotranslator enable you to run Java 5 compiled class on JRE1.4 or 1.3 in 2 ways.

1. Transform the classes/Jar into Java 1.4 compatible.
2. Run Java 5 class on JRE1.4 using Just-In-Time(JIT) Retrotranslator to translate Java 5 byte codes to Java 1.4 on the fly.

Personally i'll prefer first option (not knowing how is this Retrotranslator behaving). After using it for some time, i found it's quite stable and have no problems at all =)

Here's how you convert a Java 5 classes/Jar to Java 1.4:

java -jar retrotranslator-transformer-n.n.n.jar -advance -srcjar 

The "-advance" option is to resolve compatibility issues between Java 5 and 1.4. Such as new methods that found in Java 5 but not 1.4. But it has only limited support. After running the Command, the jar file will be converted into Java 1.4 compatible. Now you can use this Jar on JRE 1.4. 

For more information, please refer from http://retrotranslator.sourceforge.net/