Skip to main content

How to find all the jre's installed on desktop

2 replies [Last post]
Joined: 2007-01-08

I have installed JRE131, 142, 150 on my destop. How do I find out all these JRE versions using a Java Program or JavaScript?

Thanks in advance

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-12

On Windows you can query the registry key:

"HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment"

here's a method to do so:

private Vector getRegEntries( String key )
Vector results = new Vector();
try {
Process proc = Runtime.getRuntime().exec( "REG QUERY " + key );
InputStream is = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String result = "";
String line;

while (( line = br.readLine()) != null ) {
line = line.trim();
results.add( line );

return results;
catch ( Exception ex ) {
// Report Problems
// ...
return null;

You'll then have to filter the results a bit to extract the version numbers and home directories, but all the information is there.

Joined: 2003-09-10

From a Java application you can find one by calling:

File javaHome = new File(System.getProperty("java.home"));

Finding all is harder, on Windows the install locations of the JRE's are stored in the registry but with the Preference API from Java you only have limited access to the registry. You could look at the source of the Preference API and try to create one that has full access or else look for an existing one on the web. How to find the JRE's on other OSes (like Solaris, Mac OS and Linux) I don't know but maybe there are others who knows it.