Upgrading to Java 6- will it run on 5?

S

stevecanfield

If a developer builds something with Java jdk 6, do customers have to
be running a Java 6 jre to run the app? If you target version 5, will
the generated classes work on a Java 5 jre?

-sc
 
D

Daniel Pitts

If a developer builds something with Java jdk 6, do customers have to
be running a Java 6 jre to run the app? If you target version 5, will
the generated classes work on a Java 5 jre?

-sc

Thats a good question.
There are some changes to the API in 1.6, but if you avoid those that
differ, I believe 1.5 and 1.6 have compatible class formats.
 
A

Andrew Thompson

If a developer builds something with Java jdk 6, do customers have to
be running a Java 6 jre to run the app? If you target version 5, will
the generated classes work on a Java 5 jre?

So long as the build is done with a
-source/target of 1.5 (or lower) and
compiled against a -bootclasspath
pointing to a 1.5 (or lower) rt.jar,
then..

Yes. The code should run successfully
on 1.5 (or lower) VM's.

What pins the minimum at 1.5? Generics?

Andrew T.
 
S

stevecanfield

So long as the build is done with a
-source/target of 1.5 (or lower) and
compiled against a -bootclasspath
pointing to a 1.5 (or lower) rt.jar,
then..

Yes. The code should run successfully
on 1.5 (or lower) VM's.

What pins the minimum at 1.5? Generics?

Andrew T.

Yeah- we make heavy use of generics.
Unfortunately we also have a class that implements java.sql.ResultSet
and that seems to have changed between 5 and 6 (now ResultSet extends
Wrapper).

So I think once we make the jump to 1.6, all of our customers will
need to as well.

sc
 
A

Andrew Thompson

....
Unfortunately we also have a class that implements java.sql.ResultSet
and that seems to have changed between 5 and 6 (now ResultSet extends
Wrapper).

So I think once we make the jump to 1.6, all of our customers will
need to as well.

Wrong. That ResultSet now extend's Wrapper
interface is of no huge problem, perhaps unless
the application actually *de/serailizes* ResultSet's.
It merely adds to the methods that are implemented
in ResultSet (by way of the Wrapper method
contract).

Compile aginst a 1.5 rt.jar as described earlier,
and the application should run on 1.5+.

Andrew T.
 
P

Pete C

If a developer builds something with Java jdk 6, do customers have to
be running a Java 6 jre to run the app? If you target version 5, will
the generated classes work on a Java 5 jre?

-sc

My JAR-file written with JDK 1.6.0 (Java 6) couldn't run on JRE
1.5.0_10 (which is the latest Java 5 JRE). It's also still the version
users can download from www.java.com at the moment. -But my program
wasn't targeted to version 5 (I didn't think, that I had to do that),
so one should probably just tell the compiler to do that. I hope that
it will work, when I try...

By the way, what is the target option to javac, just "javac -target 5
MyFile.java" ?

Another thing: I am trying to find a place where Java users can
download JRE 1.6.0, without having to download the whole Java
Development Kit (JDK 1.6.0) too. I didn't find JRE 6 alone on
www.java.com or java.sun.com. -Only the full package with the JDK and
JRE 6 could be downloaded.

I wonder why. Does anyone know a place to download JRE 6 alone? If JRE
6 was just freely available on www.java.com, then there wouldn't
really be any problem, of course...

Rgds,
Pete C
______________________________________________
Why not have a *free* copy of StarOffice (SO7)? Try here :
http://www.avanquest.fr/absoft/prod...nt_presse/vnu/StarOffice0506/avquk_so0506.cfm
 
A

Andrew Thompson

On 2 Feb., 18:51, (e-mail address removed) wrote: ....
By the way, what is the target option to javac, just "javac -target 5
MyFile.java" ?

That will not guarantee code compatibility.
See my earliest reply, then RTFM.

Andrew T.
 
B

Ben Caradoc-Davies

Pete said:
By the way, what is the target option to javac, just "javac -target 5
MyFile.java" ?

It is more complicated than that because javac uses the java boot class
path to determine the API of the standard libraries. Sun recommend using
javac with the boot class path of the jdk for your target version. In
practice, I find it simpler to just build with the target jdk. Neither
of these approaches will help you if you have used jdk1.6-only library
features and are targeting jre1.5, because the runtime will have no
support for them. The "-target" option (mostly) only affects language
features and the version number of the class files emitted by the compiler.

Here is an example, from the javac manual page for jdk1.6.0:

******

Cross-Compilation Example

Here we use javac to compile code that will run on a 1.4 VM.

% javac -target 1.4 -bootclasspath jdk1.4.2/lib/classes.zip \
-extdirs "" OldCode.java

The -target 1.4 option ensures that the generated class files will
be compatible with 1.4 VMs. By default, javac compiles for JDK 6.

The Java Platform JDK’s javac would also by default compile against
its own bootstrap classes, so we need to tell javac to compile
against JDK 1.4 bootstrap classes instead. We do this with -boot-
classpath and -extdirs. Failing to do this might allow compilation
against a Java Platform API that would not be present on a 1.4 VM
and would fail at runtime.

******
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top