Forum Stats

  • 3,840,396 Users
  • 2,262,599 Discussions
  • 7,901,263 Comments

Discussions

JRE version from application

914035
914035 Member Posts: 14
edited Apr 16, 2019 6:46AM in Java Programming

I have a swing application that within it I want to get the java version from the user's machine.  The application that I am using, when installed, installs a self contained JRE and when I try to do a System.getProperty("java.version"), it is retrieving the java version of the self-contained JRE within the application.  I was wondering if there is another way that I would be able to get the java version from the user's machine?

Thanks in advance.

morgalr

Answers

  • morgalr
    morgalr Member Posts: 457
    edited Jan 10, 2019 7:27PM

    There are two way which I have heard of, but I have actually done neither:

    1 -- socket communication with an app running in the other JVM

    2 -- registry search

  • jwenting
    jwenting Member Posts: 4,864 Gold Badge
    edited Feb 8, 2019 2:59AM

    And a registry search is unreliable and platform specific.

    If there's multiple JVMs installed, you can't know which one is running your application at that moment.

  • jwenting
    jwenting Member Posts: 4,864 Gold Badge
    edited Feb 8, 2019 3:03AM

    What's wrong with using System.getProperty("java.version") for you?

    It returns the JVM version, which you seem to be after.

    If you want more information, there are the other properties like "java.vm.name", "java.vendor.version", and "java.vm.specification.version" that also contain information about the JVM in use.

    And then there's things like "sun.boot.library.path" and "java.home" that give specific information about the installation of the JVM.

  • morgalr
    morgalr Member Posts: 457
    edited Mar 12, 2019 8:43PM

    jwenting,

    It does not matter which JVM has your app listening, in socket communications the client and servers are listening to ports on the box.  Any active client will be able to hear your server and active server will hear your clients.

    That is as long as they are all listening on the same port and using the same protocol.

    Les

  • jwenting
    jwenting Member Posts: 4,864 Gold Badge
    edited Apr 16, 2019 6:46AM

    OP claims to be getting the wrong JVM version. He isn't, but rather the JVM under which the application is running is not the one he thinks it's running under.

    morgalr