[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Policy/recommendation on compiling with version 1.4 vs. 1.5?



Wolfgang Baer napisał(a):
> Eric Lavarde - Debian wrote:
>
>>Hi,
>>
>>my understanding of the differences between Java 1.4 and 1.5 is that
>>programs compiled with Java 1.5 might not work in the JVM 1.4, but the
>>other way around should always work.
>>
>>So my questions:
>>1. is this correct?
>
> Depends on the source :-)

That's the first approximation ;)

First, 1.4 (and earlier) programs will "always" work with 1.5 (and later). Sun lists all incompatibilities introduced in each major version. There are some, but fortunately not many.

> If the source uses 1.5 features you have to compile it with JDK 1.5
> However you can run it with older JDKs as long as it does not use new
> classes introduced in 1.5 (Enum or java.util.concurrent ...)

Yes, and remember that (AFAICT) String concatenation (+) uses StringBuilder (not StringBuffer) in 1.5, which is not available in 1.4.

> If these new classes/features are not used you can compile it either
> with 1.4 or 1.5 - but be aware to use the target=1.3 flag to be able
> to run the code in JREs from 1.3 up to 1.5

That's usually the safest way :) -source 1.x might be useful too (or even necessary).
-KS


----------------------------------------------------------------------
Startuj z INTERIA.PL! >>> http://link.interia.pl/f186c



Reply to: