How to export all installed versions of Java to a text file under Windows XP-Collection of common programming errors

Assuming your runtimes are all in the same folder, You can grab the “JAVA_HOME” environment variable then just print a list of the folders in the parent directory of wherever it points.

However individual applications can bundle their own runtimes, which can be anywhere pretty much.

Since you reference -version though, I assume you are using it from the command line so pulling in JAVA_HOME and looking around there seems like a good place to start.