Its very easy to set environment variable in Ubuntu.
Just edit the file /etc/environment and add your env variable.
Once done save and close it. Its not done yet .
Just source the file /etc/environment to make it work immediately without needing logout and relogin.
Type in command:
That's it, you can now test the environment variable by typing in command: