title: How to set environment variables for Java
body: <p>I have inserted the following lines in <code>.bash_profile</code></p>
  
  <pre><code>export GOOGLE_APPLICATION_CREDENTIALS=/Users/jun/Downloads
  export PATH=$PATH:GOOGLE_APPLICATION_CREDENTIALS
  </code></pre>
  
  <p>and the changes did take effect</p>
  
  <p><a href="https://i.stack.imgur.com/2M412.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2M412.png" alt="enter image description here"></a></p>
  
  <p>However, when I try to access the environment variable with the following method</p>
  
  <pre><code>System.out.println(System.getenv("GOOGLE_APPLICATION_CREDENTIALS"));
  </code></pre>
  
  <p>The result is <strong>NULL</strong></p>
  
  <p>Why is that?</p>
  
  <p>Note: The application is ran with Eclipse.</p>