Establecer la variable de entorno en shell script / acceso en el programa Java
Quiero configurar el entorno usando shell scripts en Ubuntu 10.04 y quiero acceder en el programa java. He escrito shell script de esta manera:
#! /bin/sh
export JAVA=/home/ubuntu
echo "Variable $JAVA"
y mi programa de java es:
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")));
}
}
Cuando ejecuto este comando sin shell script, funciona bien, pero en shell script no funciona.