Linux Blog

Making Environment Variables Stick

Filed under: General Linux — TheLinuxBlog.com at 5:00 am on Sunday, October 3, 2010

So, setting environment variables is a pretty easy task right? I thought so too but recently I was unable to read a variable I set from within a Tomcat application no matter what I tried. The problem turns out was easy to fix.

All I needed was to set an environment variable, I didn’t care who had access to it since it was just a path but whatever I did, it just wouldn’t stick. I quickly found out from a co-worker about a magical command that would have been a solution. Problem now was he couldn’t remember what it was. Well it turns out that it is a bash built in called source. Using this with the /etc/profile file as follows: “source /etc/profile” fixed the problem without a reboot.