I need to set a system environment variable for Java. I'm currently using this method:
setx /M JAVA_HOME "C:\Program Files (x86)\Java\jdk1.6.0_17"
My question: Is there a better (PowerShell) way to do this?
I tried using:
[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files (x86)\Java\jdk1.6.0_17")
But this does not produce the same result as setx.
Is there a better PowerShell way to set Java home?
Did you try to set the scope?
[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files (x86)\Java\jdk1.6.0_17", "Machine")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With