Reputation: 6224
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?
Upvotes: 0
Views: 586
Reputation: 42037
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.
Upvotes: 1