Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check which version of Java is installed before a user tries to run an application?

Tags:

java

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?

like image 670
BJ Dela Cruz Avatar asked Oct 17 '25 18:10

BJ Dela Cruz


1 Answers

Check the System.getProperty("java.version")

You'll need to do some parsing, but this should give you a jumping of point

like image 114
MadProgrammer Avatar answered Oct 20 '25 08:10

MadProgrammer