Possible Duplicate:
How to check JRE version prior to launch?
Many people want to know how to force their program to use a minimum version of a jre, but I would like my program to only run using java 6 and not java 7 (aka maximum of jre 1.6). The reason being that my program needs to use FTP, and java 7 has the dreaded FTP bug.
Is there a way to easily make my application run using 1.6 if the user has 1.7 installed?
Some of the options I have looked at are: launch4j
I am not quite certain that it will solve my problem, other than perhaps bundling the entire jre with my program. Which I don’t think is the most ideal solution.
Can someone help guide me even down the theoretical path as to how this is generally solved/handled?
As suggested in this somewhat related question/answer, use
System.getProperty("java.version")to see what version of Java is being used to run the application. With this you can make the application prompt the user that he should use an older JRE.As for running the application without path based JRE detection, the main problem is that you can’t be certain where on the user’s system the correct JRE is installed. On Windows there’s two default possibilities, on *nix it might be anywhere.
If I were you, I’d try to find a custom FTP library that gets around the bug you mentioned to get the maximum security and optimization benefits of the newer versions of Java instead of forcing the user to stay in the past.