Created
November 1, 2020 09:46
-
-
Save Wuvist/4096619edd4fdadc1810555b90db166d to your computer and use it in GitHub Desktop.
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
function setJava { | |
param ( | |
[string]$version | |
) | |
$javaEnvs = @{ | |
j8 = 'C:\java\jdk1.8.0_241' | |
j11 = "C:\java\jdk-11.0.9" | |
g8 = 'C:\java\graalvm-ce-java8-20.2.0' | |
} | |
$path = $Env:PATH | |
$javaEnvs.Values | ForEach-Object { | |
$val = $_ -replace "\\", "\\" | |
$path = $path -replace ";$val\\bin;", ";" | |
} | |
$Env:PATH = $javaEnvs[$version] + "\bin;" + $path | |
$Env:JAVA_HOME = $javaEnvs[$version] | |
java -version | |
} | |
function j8 { | |
setJava "j8" | |
} | |
function j11 { | |
setJava "j11" | |
} | |
function g8 { | |
setJava "g8" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment