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!
-
stackoverflow.com/questions/5103121/… also, if you're targeting Windows try this -> launch4j.sourceforge.net you can bundle the JVM with it if it is critical or just throw an error message.Daniel B. Chapman– Daniel B. Chapman2013年10月29日 18:17:34 +00:00Commented Oct 29, 2013 at 18:17
-
possible duplicate of Getting version of java in runtimeDarwind– Darwind2013年10月29日 18:18:14 +00:00Commented Oct 29, 2013 at 18:18
2 Answers 2
System.getProperty("java.version");
1 Comment
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.