Skip to content

Instantly share code, notes, and snippets.

@mark05e
Created March 4, 2019 06:52
Show Gist options
  • Save mark05e/9208c92bfc1e18eb293d38749e2853b7 to your computer and use it in GitHub Desktop.
Save mark05e/9208c92bfc1e18eb293d38749e2853b7 to your computer and use it in GitHub Desktop.
To display all installed Java versions using powershell
# Reference: https://www.experts-exchange.com/questions/28995393/check-java-version-using-powershell.html
'', 'Wow6432Node\' |
ForEach-Object {Get-ItemProperty -Path HKLM:\SOFTWARE\$($_)Microsoft\Windows\CurrentVersion\Uninstall\* |
Where-Object {($_.DisplayName -like '*Java *') -and (-not $_.SystemComponent)} |
Select-Object DisplayName, DisplayVersion, InstallLocation, @{n='Architecture'; e={If ($_.PSParentPath -like '*Wow6432Node*') {'x86'} Else {'x64'}}}}
@mark05e
Copy link
Author

mark05e commented Mar 4, 2019

Sample output:

DisplayName                DisplayVersion InstallLocation                           Architecture
-----------                -------------- ---------------                           ------------
Java 8 Update 191 (64-bit) 8.0.1910.12    C:\Program Files\Java\jre1.8.0_191\       x64
Java 8 Update 201 (64-bit) 8.0.2010.9     C:\Program Files\Java\jre1.8.0_201\       x64
Java 8 Update 161          8.0.1610.12    C:\Program Files (x86)\Java\jre1.8.0_161\ x86
Java 8 Update 201          8.0.2010.9     C:\Program Files (x86)\Java\jre1.8.0_201\ x86

@TATS03
Copy link

TATS03 commented Jul 1, 2024

haw do i use it ?

@mark05e
Copy link
Author

mark05e commented Jul 3, 2024

Its been a while but I'd assume you run it by copy pasting the command into powershell. @TATS03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment