Last active
December 2, 2022 00:48
-
-
Save C-K-Loan/6bc17d936c5fbeda8a67f498dfaa63b8 to your computer and use it in GitHub Desktop.
Update Environment Variables Dynamically with Scala
This file contains hidden or 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
| def setEnv(key: String, value: String) = { | |
| val field = System.getenv().getClass.getDeclaredField("m") | |
| field.setAccessible(true) | |
| val map = field.get(System.getenv()).asInstanceOf[java.util.Map[java.lang.String, java.lang.String]] | |
| map.put(key, value) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment