-2

How to check, is Java is installed on Windows systems ?

mjn
  • 35,561
  • 24
  • 160
  • 351
waza123
  • 2,152
  • 2
  • 25
  • 42
  • See also this answer with detailed registry key information: http://stackoverflow.com/a/3930458/80901 – mjn Sep 18 '12 at 06:00
  • @mjn the problem is that registry is just a cache here. If you found Java in registry - you still have to check it, if it is actually present on disk and is modern enough. If you did not found Java in registry, that still means nothing: it could be present on disk as part of Lotus Notes or Oracle Office just no shortcut in registry created. For "try run some java" registry check followed by java test would be enought usually. But that test is not reliable. – Arioch 'The Sep 18 '12 at 09:01
  • @Arioch'The the registry entries only are helpful if they can be validated (the given paths actually contain a JRE), this answer link was given for this additional information only, as I tried to list other possible situations in my answer below – mjn Sep 18 '12 at 09:42
  • 2
    Why the downvotes - is it just [Javaphobia](http://www.problemfactory.com/) or something serious? – mjn Sep 18 '12 at 09:46

4 Answers4

4

You can read this out of the registry. Look in this key:

HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment

and read the string value named:

CurrentVersion

This setting lives in the 32 bit view of the registry, so if you ever build 64 bit code make sure you include the KEY_WOW64_32KEY flag.

David Heffernan
  • 572,264
  • 40
  • 974
  • 1,389
1

Visit the officail website http://www.java.com/en/download/testjava.jsp and click "test currently installed version of java"

Ashwin Singh
  • 6,679
  • 3
  • 32
  • 54
  • 2
    Fail is rather strong and confrontational. I guess you didn't mean it that way. But rather than just tagging the question would have been a little better if it had explicitly said that you wanted to test programatically. – David Heffernan Aug 05 '12 at 15:03
  • 2
    @David: I do agree with you, but one could also argue that a programmatic approach is understood to be desired by the OP because, if not, the OP would have posted his question on the wrong forum (SO instead of SU). [Not saying that is unusual, though...] – Andreas Rejbrand Aug 05 '12 at 15:57
  • @AndreasRejbrand - but this answer also *can* be implemented in Delphi, though it would be rather exotic method. But regarding Java the only complete solution would be scanning the full disk and checking found java versions. – Arioch 'The Sep 18 '12 at 08:56
1

Some information which might be helpful:

  • a Java run time environment (JRE) can be installed by simply copying it to the computer (no Windows system entries are required)
  • there can be many different JRE versions on the computer at the same time (many commercial apps are bundled with their own JRE)
  • your Delphi app could check whether there is a java.exe in the system path (and so avoid scanning all folders)
  • the JAVA_HOME environment variable normally indicates the location of the Java Development Kit (JDK), but in a typical installation the JDK directory also contains a JRE folder
mjn
  • 35,561
  • 24
  • 160
  • 351
0

For my Inno Setup I check this key :

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\javaw.exe

If I remove JAVA the key doesn't exist anymore.

athspk
  • 6,576
  • 7
  • 32
  • 51
  • one similar key can be HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths --- I wonder if IBM J9 registers in those keys though – Arioch 'The Sep 18 '12 at 08:53