11

This may be a very simple problem, but I couldn't find an answer googleing and I'm in a rush - so I'd appreciate fast code examples.

I have an environment variable on the OS I would like to read using Java code. I've tried System.getProperty, but that only seems to work for the -D variables supplied directly for the JVM.

How can my Java code read OS variables?

Jonik
  • 80,077
  • 70
  • 264
  • 372
Amir Arad
  • 6,724
  • 9
  • 42
  • 49
  • 2
    seriously? I was here first... – Amir Arad Dec 16 '13 at 13:48
  • 1
    The other question has a much better answer by today's standards of SO, and it was suggested as duplicate of this. It makes more sense to have duplicate this way. No offence meant in any way. – hyde Dec 16 '13 at 14:43
  • 1
    none taken, I'm mostly bewildered and amused. Thanks for the explanation. The other question specifically states that this here *accepted* answer does not solve the problem. what makes people think it's the same thing? – Amir Arad Dec 16 '13 at 17:10

1 Answers1

29

Try System.getenv(String name)

bruno conde
  • 47,767
  • 15
  • 98
  • 117