Definir a variável de ambiente no script de shell / acesso no programa Java

Eu quero definir o ambiente usando o shell script no Ubuntu 10.04 e deseja acessar no programa java. Eu escrevi o shell script assim:

<code>#! /bin/sh
export JAVA=/home/ubuntu
echo "Variable $JAVA"
</code>

e meu programa java é:

<code>import java.util.Map;

public class SystemEnv
{
    public static void main(String[] args)
    {

        Map<String, String> variables = System.getenv();
        for (Map.Entry<String, String> entry : variables.entrySet())
        {
           String name = entry.getKey();
           String value = entry.getValue();
           System.out.println(name + "=" + value);
        }
        System.out.println(System.getenv(("JAVA")));
    }
}
</code>

Quando eu executo este comando sem shell script ele funciona bem, mas no shell script ele não funciona.

questionAnswers(2)

yourAnswerToTheQuestion