Define "which JVM." JVM version, or path to the executable? If it's the former, just check the "java.version" system property. If it's the latter, you may be able to use Class.getResource() to get a file:// URL for a System class file, then examine the URL for a local path.
The system I am wokring on may be having multiple versions of JVM. SO I guess to find version I will have to go second route you pointed. This might be bigginer question, Can you eloborate how do I use Class.getResource? I have .jar files in a directory and I want to find which JVM each one is using.
Thanks for your reponse Gemini
Ernest Friedman-Hill
,
author and iconoclast
staff
I have .jar files in a directory and I want to find which JVM each one is using.
Nothing about a jar file itself will tell your computer what JVM to use; it depends only and entirely on your computer's settings. If we're talking about a jar file you double-click to execute, then you need to look at the OS's file association for jar files, and possibly (if the association doesn't specify a path) your PATH environment variable to see which version of "java" is first on the path.