> You could have your program detect the Java version and refuse to run for
> certain values.
That could cause ugly exceptions depending on (1) the JDK the app was
built on and (2) the JRE the end user is running on.
For example, I believe (this is from memory, so I could be wrong) if an
app built on a Java 5 JDK is run on a JRE 1.4.x VM, an
UnsupportedMajorMinorException is thrown due to the different
serialVersionUID.
Oliver Wong - 21 Mar 2006 17:44 GMT
>> You could have your program detect the Java version and refuse to run for
>> certain values.
[quoted text clipped - 5 lines]
> UnsupportedMajorMinorException is thrown due to the different
> serialVersionUID.
So catch those, and show a pop up saying "Please upgrade your JVM". ;)
- Oliver
Joe Attardi - 21 Mar 2006 17:57 GMT
> So catch those, and show a pop up saying "Please upgrade your JVM". ;)
:-) Then there's that.
But actually, I think that would be thrown as soon as the main class is
loaded, which I would think would stop any further execution of the
program.
Alun Harford - 21 Mar 2006 18:45 GMT
>> You could have your program detect the Java version and refuse to run for
>> certain values.
[quoted text clipped - 5 lines]
> UnsupportedMajorMinorException is thrown due to the different
> serialVersionUID.
You are indeed wrong.
Alun Harford
Joe Attardi - 21 Mar 2006 19:17 GMT
> For example, I believe (this is from memory, so I could be wrong) if an
> app built on a Java 5 JDK is run on a JRE 1.4.x VM, an
> UnsupportedMajorMinorException is thrown due to the different
> serialVersionUID.
Correction:
I was mixing up class version with serialVersionUID. The actual
exception that would be thrown is UnsupportedClassVersionError, with a
message stating "Unsupported major.minor version 49.0".
This would be thrown _as soon_ as the main class is loaded, before
main() gets executed. So detecting older JREs programmatically would
_not_ work...
lewmania942@yahoo.fr - 21 Mar 2006 19:31 GMT
Hi,
> For example, I believe (this is from memory, so I could be wrong) if an
> app built on a Java 5 JDK is run on a JRE 1.4.x VM, an
> UnsupportedMajorMinorException is thrown due to the different
> serialVersionUID.
You're thinking of UnsupportedClassVersionError (Unsupported
major.minor version xx.x). Note however that you can "-target",
say, an 1.4 JVM using an 1.5 compiler.
Here's an example of the exception you're thinking of:
...$ java -jar /home/example/fakejar42.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError:
com/fake/FakeJar (Unsupported major.minor version 49.0)
The serialVersionUID isn't related to this however (which may be
what Alun Harford was referring to but it's not clear from his
very verbose and very informative post ;)