0

How can I determine java version installed on a system through java code, if its not latest then download and install the required jre?

3
  • 1
    The second half of this question is way, way too broad. It's also probably easier to just warn the user if his JRE version isn't supported and have him update it on his own. Commented Jul 17, 2012 at 19:47
  • 2
    System.getProperty("java.version"); Also agree with millimoose. Commented Jul 17, 2012 at 19:48
  • 1
    public bool isJavaInstalled() { return true; } Commented Jul 17, 2012 at 19:53

5 Answers 5

4

The first question is easy, use System.getProperty to get java.version:

System.getProperty("java.version")

The second part, I would instead show the user a popup dialog and ask him to download the latest (or required) version from Oracle (or some other source).

Sign up to request clarification or add additional context in comments.

Comments

0

If you have windows you can check the version by using this script:

DOS script to check if the default java installed version is greater than 1.x

Comments

0

System.getProperty(); allows you to access such information. http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/System.html java.version is one such property. You can't programmatically reinstall the java environment. All you can do is ask the user to do it themselves, maybe give them a link to the download if you want.

Comments

0

It shouldn't be necessary to check the JRE version, since the bytecode will only run in a JRE at least as recent as the one it was compiled for.

Comments

0

As adChilds said in a comment, to get the current java version installed use System.getProperty("java.version") which returns a string or null.

As for the second question, one way you could do this is by packaging the installation executable for the version that you want with your application and then executing it through code.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.