Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

force java version

Thread view: 
tiewknvc9 - 21 Mar 2006 16:41 GMT
is there a way to require a certain java version (or better) on the
users machine?
Oliver Wong - 21 Mar 2006 17:14 GMT
> is there a way to require a certain java version (or better) on the
> users machine?

   You could politely ask the user to ensure that they have a certain
version of Java on the download page, or shrink wrap packaging of your
software, and offer to download and/or install the latest version for them.
You could have your program detect the Java version and refuse to run for
certain values.

   - Oliver
Joe Attardi - 21 Mar 2006 17:19 GMT
> 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 ;)
Roedy Green - 21 Mar 2006 18:51 GMT
>is there a way to require a certain java version (or better) on the
>users machine?

there is in Java Web Start.  

Further, an app can test the version early and refuse to run if it
inappropriate.  See http://mindprod.com/products1.html#COMMON11 for
source code to do the test.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

tiewknvc9 - 21 Mar 2006 21:38 GMT
are you talking about the download for "comparator"?
tiewknvc9 - 21 Mar 2006 21:41 GMT
its under - Common JDK 1.1+ Utility classes


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.