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/

8 comments:

Anonymous said...

i totally understand how u felt back then hehe... this compatibility issue gave me hell lots of work to do before i can really start my task... what doesnt kill us make us stronger eh? :D

James Strachan said...

FWIW I've used option 2 quite a few times (e.g. using Apache Camel inside old WebSphere) - its loads easier when you've lots of jars. All it does is swizzle the bytecode on class load so its quite low risk.

ckming said...

Yeah, option 2 might be a better alternative considering if you're running with lots of jars on Java 5. For my case i only need to translate 3 jars which is still okay using option 1. But thanks for letting me know that is all fine using option 2 =)

Anonymous said...

viagra from india videos viagra buy viagra in england generic brands of viagra online uk viagra sales cheap generic viagra viagra 100mg does viagra really work guaranteed cheapest viagra viagra professional 2007 viagra hmo buy viagra without prescription viagra and alcohol viagra herb alternative

Anonymous said...

Hello!
my name is Tom and im completely new to this forum.

I hope that I'll learn and share a lot of interesting things.


Thanks!

Anonymous said...

Good dispatch and this mail helped me alot in my college assignement. Say thank you you for your information.

Anonymous said...

You could easily be making money online in the underground world of [URL=http://www.www.blackhatmoneymaker.com]blackhat code[/URL], You are far from alone if you don't know what blackhat is. Blackhat marketing uses little-known or not-so-known ways to generate an income online.

Air Jordan Retro 4 shoes said...

Thanks for posting, I really enjoyed your most recent post. I think you should post more often, you obviously have natural ability for blogging!
by Air Jordan Retro 4 shoes