Skip to content

Instantly share code, notes, and snippets.

View se35710's full-sized avatar

Mathias Hermansson se35710

  • Göteborg, Sweden
View GitHub Profile
@se35710
se35710 / find-java.ps1
Last active November 25, 2023 18:08
PowerShell script to locate Java on Windows, optionally sets JAVA_HOME and JRE_HOME.
<#
.SYNOPSIS
Locates Java versions and optionally sets JAVA_HOME and JRE_HOME.
.DESCRIPTION
The Find-Java function uses PATH, JAVA_HOME, JRE_HOME and Windows Registry to retrieve installed Java versions.
If run with no options, the first Java found is printed on the console.
.PARAMETER Vendor
Selects Java vendor, currently supports Oracle, OpenJDK and IBM. Defaults to Any.
.PARAMETER Architecture
What processor architecture to match. Valid options are 32, 64, Match and All. Match detects what integer size is used for the PowerShell process, and matches the architecture. If Wow64 is available, 64 bit versions of Java are selected first.