Angus Comber wrote:ie if I have used Java 1.6 features but user of application only has say JVM v1.1? What will happen? How do I deal with this issue?
There are two possibilities:
1) the code is not compiled to explicitly be able to run on an older JVM (using the -target compiler flag). You'll get an UnsupportedClassVersionError.
2) the code is compiled to explicitly be able to run on an older JVM, but a method, field or class is simply not there. You'll get an NoSuchMethodError, NoSuchFieldError or NoClassDefFoundError.
Another related question, if I write a Java applet should I only use features up to Java v1.1 to assure applet will run correctly if workstation has not installed a current JVM?
Well, you can either require your clients to use an up-to-date version, or use only features of an older version. I definitely would not go back to Java 1.1; the oldest version I'd even consider is Java 1.4. That one's over 9.5 years old, Java 5.0 is almost 7 years old and Java 6 is almost 5 years old. Both 1.4 and 5.0 have been end-of-life for a few years as well. I would probably require my users to use Java 6; if they still have an older version they really need to upgrade, if not for the features, then for performance and especially security.
Reason for Java 1.1 comment was I thought applets running in a web browser could only use features up to Java 1.1 if Java JVM was not explicitly installed (because web browsers used their own java engine which only generally supported uo tp v1.1 features). But this might be really old information.
So really my question is if a workstation has just a web browser, eg IE 6 and Java JVM has not been installed, will the applet run? And if it will run, what version level of features can be used? My information from a long time ago was up to v1.1.
Microsoft's own JVM had support up to Java 1.1, but if I remember correctly they are no longer allowed to distribute it. That means that these days, if no JVM is explicitly installed, applets simply will not run. There are ways to prompt the user to install a JVM, but I can't really remember how to... For some browsers like Firefox there is built-in support for finding the required plugin.
Rob Spoor wrote:Microsoft's own JVM had support up to Java 1.1, but if I remember correctly they are no longer allowed to distribute it.
If I'm not mistaken that court case was settled in 2004. It's possible that there are still computers which still have the Microsoft JVM installed in their browser (Internet Explorer 3?) because they haven't been upgraded for the last seven years, but if I were writing an applet (which I have done) I wouldn't bother trying to support them.
One elegant way of handling this issue could be using Java Web Start Using JWS you can figure out the client JVM version and prompt an update if required.
Please not, we also have a JWS and JNLP forum which has all kinds of discussions on this topic. Browsing around that forum should provide you with much more insight.