Bit Fracture Bit Fracture - 9 months ago 44
Java Question

How to verify Java version on my program launch?

My java application requires users to have Java 7 installed. However, if they don't, nothing is displayed or returned to the user unless they started the application from the console. The app simply terminates.

How would I generate a popup displaying a link to the correct version of Java in the case that the user doesn't have the correct one already?


Thanks for any help

Answer Source

You can use System.getProperty("java.version") to get the java version in a program compiled for all version . You can then make this program launch your main application/game otherwise redirect user to install JRE 7.

The correct way to do this would be to verify it during game installation as well as during launch.

Your launcher should be compiled in lowest JDK version possible for it, like ,

javac file.java -source 1.3

If possible keep your launcher as .bat/.sh file so you can be sure that launcher would not fail if java is missing

see this for example ,

Check if JAVA_HOME is present in environment using batch script