title: Set environment variable in shell script/access in Java program
body: <p>I want to set environment using shell scrip in Ubuntu 10.04 and want to access in java program. I have wrote shell script like this: </p>
  
  <pre><code>#! /bin/sh
  export JAVA=/home/ubuntu
  echo "Variable $JAVA"
  </code></pre>
  
  <p>and my java program is :</p>
  
  <pre><code>import java.util.Map;
  
  public class SystemEnv
  {
      public static void main(String[] args)
      {
  
          Map&lt;String, String&gt; variables = System.getenv();
          for (Map.Entry&lt;String, String&gt; entry : variables.entrySet())
          {
             String name = entry.getKey();
             String value = entry.getValue();
             System.out.println(name + "=" + value);
          }
          System.out.println(System.getenv(("JAVA")));
      }
  }
  </code></pre>
  
  <p>When I execute this command without shell script it works well, but in shell script it does not.</p>