-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Java rehoming; fix cert filtering
- Loading branch information
1 parent
f6250cc
commit 253f560
Showing
3 changed files
with
52 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<# | ||
.Synopsis | ||
Switch the Java version for the current process by modifying environment variables. | ||
.Parameter Path | ||
The path to the JRE/JDK to use, which must contain bin\java.exe. | ||
.Inputs | ||
System.String path to use as the new JAVA_HOME environment variable. | ||
.Example | ||
Use-Java.ps1 "$env:ProgramFiles\OpenJDK\jdk-11.0.1" | ||
#> | ||
|
||
[CmdletBinding()] Param( | ||
[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName)] | ||
[ValidateScript({(Test-Path $_ -PathType Container) -and (Test-Path "$_\bin\java.exe" -PathType Leaf)})] | ||
[Alias('FullName')][string]$Path | ||
) | ||
|
||
$env:JAVA_HOME = $Path | ||
Write-Verbose "JAVA_HOME=$env:JAVA_HOME" | ||
if($env:JDK_HOME) | ||
{ | ||
$env:JDK_HOME = $env:JAVA_HOME | ||
Write-Verbose "JDK_HOME=$env:JDK_HOME" | ||
} | ||
if($env:JRE_HOME -and (Test-Path "$env:JAVA_HOME\jre" -PathType Container)) | ||
{ | ||
$env:JRE_HOME = "$env:JAVA_HOME\jre" | ||
Write-Verbose "JRE_HOME=$env:JRE_HOME" | ||
} | ||
if($env:CLASSPATH) | ||
{ | ||
$env:CLASSPATH = ".;$env:JAVA_HOME\lib;$env:JAVA_HOME\jre\lib" | ||
Write-Verbose "CLASSPATH=$env:CLASSPATH" | ||
} | ||
$env:Path = ($env:Path -split ';' |% {if($_ -match 'Java|JDK'){"$Path\bin"}else{$_}}) -join ';' | ||
Write-Verbose "Path=$($env:Path -replace ';',([Environment]::NewLine))" | ||
${java.exe} = (Get-Command java.exe -CommandType Application).Path | ||
Write-Verbose "Using Java ${java.exe} ($((Get-Item ${java.exe}).VersionInfo.ProductVersion))" |