I am trying to print the a system variable in windows in scala. This is the code that I have written. I am getting null.
println(System.getenv("HOME"))
How do I get and print system variables in scala?
The reason you are getting null is that the variable isn't set in the context of the process. If it's set in the shell, it still might not be exported. Try
$ export HOME='....'
and then start your Scala program from the same shell session.
System.getenvorSystem.getenv.keySetin the Scala REPL to see what environment variables are visible to Scala