0

I want to create an Executable Jar file that when run, checks the currently installed version of Java on that computer and displays it for the user. I have searched online but in vain, I cannot find any code that allows a Jar file to check. I know that the Java website has it ( http://www.java.com/en/download/installed.jsp) I can't find a way to replicate it in Java Code. Any help would be very much appreciated.

Note: Sorry if this question is really stupid and has a really simple answer... I just spent half an hour trying to find a solution and I couldn't so I need your help! Thanks

Edit: I don't need the code for displaying it, just to get the version is enough for me thanks!

XQEWR
  • 638
  • 3
  • 11
  • 24
  • http://stackoverflow.com/questions/5103121/how-to-find-the-jvm-version-from-a-java-program also, if you're targeting Windows try this -> http://launch4j.sourceforge.net/ you can bundle the JVM with it if it is critical or just throw an error message. – Daniel B. Chapman Oct 29 '13 at 18:17
  • possible duplicate of [Getting version of java in runtime](http://stackoverflow.com/questions/2591083/getting-version-of-java-in-runtime) – Darwind Oct 29 '13 at 18:18

2 Answers2

5

System.getProperty("java.version");

Kal
  • 24,724
  • 7
  • 65
  • 65
1

Calling System.getProperty("java.version"); will give you version of the installed JRE which is what you want. Also take a look at other System properties, you may find some of them also useful.

Petr Mensik
  • 26,874
  • 17
  • 90
  • 115