0

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?

1
  • Run System.getenv or System.getenv.keySet in the Scala REPL to see what environment variables are visible to Scala Commented Jun 2, 2015 at 15:47

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@eddard.stark No, the process launching the JVM has to have these values exported

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.