Setting Environment Variables

MidnightJava

Registered
I'm new to OSX and Unix as well, and having trouble doing a very simple task. I just want to set an environment variable, java_home.

I'm using the BASH shell by default. I created a file named .bash_login, placed it in my home directory, and put the following line in it

java_home=/library/java/home/bin

Then in Terminal I executed

bash -login
printenv

The java_home variable is not defined.

What am I missing?
 
I did the same thing, no need to do bash -login, it executes it automatically. try typing either:
Code:
set | grep "java"
or
Code:
echo $java_home

and you should see it.

What you did worked for me if I did set or echo, printenv doesn't show it.
 
Not sure this was my problem. It's not just that it didn't show up with printenv, but when I tried to startup Tomcat web server it complained that java_home was not set.

I discovered somewhere that I have to enter "expoprt java_home" in the login script, or the variable setting will just be scoped internal to the script. Funny that the tutorial I was looking at didn't mention anything about this, but the next link on google gave me the complete story. So it's working now. Thanks for your reply.
 
Back
Top