Thursday, March 13, 2008

How many JRE on my Windows machine

Today we are doing some discussion on JRE and one of my friends Lawrence asked me a question "How to find how many JRE are installed on system by Java Code ? " Now I don't think Java have any such API which will tell how many JRE are installed on System and what are they ? But my another friend Vikram has a saying that JRE installation write information in Registry. And here I tried to write this code. It will only run on Windows :) because again I have used Runtime class. I would love to know how the same could be achieved in Unix Systems. This code is not doing anything, just do query from registry and reflects the answer on the console.

class NoofJRE {
static String REG_PATH = "reg query " +
"\"HKLM\\Software\\JavaSoft\\Java Runtime Environment";

public static void getJREInfo() {
try {
Process process = Runtime.getRuntime().exec(REG_PATH);
InputStream inputstream = process.getInputStream();
InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
String line;
while ((line = bufferedreader.readLine()) != null) {
catch (Exception e) {
System.out.println("I am in Exception");
public static void main(String s[]) {

And here is my output:

E:\Program Files\Java\jdk1.6.0\bin>java NoofJRE
HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment
CurrentVersion REG_SZ 1.6
BrowserJavaVersion REG_SZ 1.6.0_01
HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\1.4.2_17
HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\1.6
HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\1.6.0
HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\1.6.0_01

Which sounds true in my case. It is clearly telling me that I have JRE 1.4.2_17, 1.6.0 and 1.6.0_01. I have old bad habit on not uninstalling JRE's :). Please let me know if there is any other way to know how many and which JRE is/are installed in my system.

And to know where it is installed is also easy by querying JAVA_HOME in registry value.


Anonymous said...

Can anyone recommend the best IT automation tool for a small IT service company like mine? Does anyone use or How do they compare to these guys I found recently: N-able N-central remote software access
? What is your best take in cost vs performance among those three? I need a good advice please... Thanks in advance!

Anonymous said...


[url=]electronic cigarette buy kentucky retailer [/url]
cigarettes by money orders buy cigarettes as buy misty cigarettes free shipping
[url=]buying cigarettes [/url]
cigarettes buy best buy pop up cigarette case buy cigarettes canada online
[url=]where to buy herbal cigarettes [/url]
money order cigarette purchases buying online l&m menthol lights cigarettes buy cigarettes in south
[url=]cheapest states to buy cigarettes [/url]
where mto buy cigarettes in nys buy cheap cigarette newport buy cigarettes over
[url=]buy cigarettes in spain [/url]
order cigarettes online buy all natural cigarettes online buy cigarette accessories
[url=]order discount cigarettes online [/url]
buy cigarette marlboro online best place online to buy cigarettes buy cigarette tips
[url=]buy marloboro light cigarettes online [/url]
buy empty cigarette packs on line buying cigarettes online forum buying marlboro cigarettes online
[url=]buy cigarettes on the [/url]
e cigarette where to buy it buy cigarettes from russia buy cigarettes from kentucky
[url=]buy echo cigarettes [/url]
buy cigarettes in florida electronic cigarette cartridge order buy misty cigarettes free shipping
[url=]buy newport cigarette [/url]
where to buy fake cigarettes age to buy cigarettes in pa buy misty cigarettes online

Anonymous said...

Hi everyone

Mansour Engineering have a refined understanding of client and market priorities in all facets of mechanical, electrical and civil engineering from engineering assessments and studies through typical and specialized design commissions, document production, contract administration, design/build, energy studies, field inspection and supervision, to building systems commissioning and consulting services for building operations

[url=] click here to go to Mansour Engineering[/url]

Anonymous said...

Amiable dispatch and this post helped me alot in my college assignement. Gratefulness you for your information.