Running separate applet 1.1 and 1.4 versions

Hi, this is for applets. I’m trying to run my game to work on both 1.1 and 1.4, there are separate JAR versions for each, is there an easy way to make 1.4 run if it’s there, else use 1.1? Can someone show me code that can do this?

Thanks!

I didn’t understand you very well but I think you can complile the with jdk 1.1 and it will work with both jre 1.1 and 1.4.The only problem is that the performance will be poor.

Write a class that has a very simple method for loading the applet, which looks at the System properties for java version, and works out whether the java version is less than 1.4.

If so, instantiate the main class from the 1.1 jar and re-route all calls in your applet to that class (which should be an applet itself, basically).

If not, instantiate the main calss from the 1.4 jar, and … etc.

Probably a good idea to look up the “design patterns” known as “facade” and “proxy” - you should get the idea.

You dont necesarily need to have two complete different jar’s for the game…

If you’d stick to methods and classes available since jdk 1.1 (you can check this in the java api doc) and compile your work as 1.1 compatible byte code your fine. (on the 1.5 jdk compile with the -target 1.1 -source 1.3 options)

Of course you might want to take advantage of new classes/methods available in VM’s>1.1. Then you should use a design pattern like Blahblahblah pointed out; a factory pattern could help you with this. For example you could check whether the VolatileImage class is available on the VM your game is running on, if so, use your VolatileImageSprite class or else (on VM’s <1.4) use your ImageSprite class.