I'm trying to set an environmental variable in linux. I followed the instructions here: Make $JAVA_HOME easily changable in Ubuntu
Despite using source /etc/environment
and using echo MY_VAR
to verify that linux detects the variable, my java app will not pick up on it. The variable continues to return null
public static void main(String[] args) throws IOException {
System.out.print(System.getenv("MY_VAR"));
I'm executing my java application via sudo java -jar /path/to/my.jar
Update: My mistake, I hadn't included the correct command. I'm actually sudoing.