Reputation: 5354
If a user double-clicks on an executable JAR file, is it possible to check what version of Java that he or she has installed, and then display an appropriate message in a window that says that he or she needs to have X version of Java to run the application?
I am creating an application that requires Java 7, and if a user does not have that version installed, I would like to display a message that says that he or she needs to download and install it.
Of course, the user can type java -version
, but it would be nice to display the version in a window for those who don't know how to check what version is installed. Is it possible to do so?
Or should I run some type of script to check before launching the application?
Upvotes: 4
Views: 177
Reputation: 5516
You can get the java version by using
System.getProperty("java.version")
See the documentation (http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html)
Upvotes: 2
Reputation: 347184
Check the System.getProperty("java.version")
You'll need to do some parsing, but this should give you a jumping of point
Upvotes: 3