Java Swing 1.6 to 1.5

javaswing

Is it possible to port a UI developed using Swing in Java 1.6 to Java 1.5 without rewriting all again?

Best Solution

Just to elaborate on what duffymo said:

Java is designed to be backward compatible. I.e. if you write something in 1.5 you can run it in 1.6. Of course there are limits to that (e.g. new reserved words like assert break it) but in general it works fine.

If you go the other way, it's a bit more dangerous. You certainly won't need to rewrite all your code, but you might have used features only available since 1.6. Such features can be new classes or new methods of existing classes.

Another thing is the binary code level. You can set your compiler running 1.6 to create code for 1.5 or even 1.4.

But beware, that your 1.6 compiler most certainly compiles against a 1.6 rt.jar. That means you won't notice missing classes or methods until you actually run or compile your code with 1.5.

Setting the compliance level only means that the 1.5 JRE will understand the code, not that all "default" classes are available.

I don't have any experience with 1.6 specifics, but i think while 1.5 added a lot of new language features (that are not all compatible with 1.4), 1.6 was more of a maintenance release.