Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-03-2006, 02:42 PM   #1
LQ Newbie
Registered: Feb 2006
Posts: 4

Rep: Reputation: 0
exporting JAVA_HOME, PGDATA, etc

I'm kinda of hazy on the difference between running the following three commands:
#: JAVA_HOME=/usr/java
#: export JAVA_HOME=/usr/java

Could somebody help clear this up please?
Old 03-04-2006, 12:32 AM   #2
LQ Newbie
Registered: Feb 2006
Location: Quito-Ecuador
Distribution: Debian 3.1, Fedora Core 4
Posts: 18

Rep: Reputation: 0
What you are doing in the three commands is setting environment variables for the shell (the command interpreter) you are working with. With the BASH shell "JAVA_HOME=/usr/java" and "export JAVA_HOME=/usr/java" are equivalent. "PATH=/usr/java/:$PATH" ads the path "/usr/java/" at the beginning of the PATH variable. It is as simple as that.
Old 03-06-2006, 10:49 AM   #3
LQ Newbie
Registered: Feb 2006
Posts: 4

Original Poster
Rep: Reputation: 0
thank you very much. That really clears that up.
Old 03-06-2006, 07:35 PM   #4
LQ Newbie
Registered: Feb 2006
Location: Quito-Ecuador
Distribution: Debian 3.1, Fedora Core 4
Posts: 18

Rep: Reputation: 0
You are welcome.
Keep asking...a good way to learn.
Old 03-06-2006, 08:25 PM   #5
Registered: Dec 2002
Location: St Louis, MO
Distribution: Arch Linux
Posts: 99

Rep: Reputation: 15
Actually, they are not quite the same. When a script assigns a variable it is generally considered a local variable. If you export that variable it allows sub shells access to that variable.

For instance if you create 2 scripts, the first one assigns 2 variables (say v1 and v2) but only exports v2, you then call the second script from the first, the second script will know nothing about v1 but will know about v2.

test1 script: (copy below)

# test1 environment variable script
e1="non-exported variable"
e2="exported variable"
export e2
echo "Test 1 Program Environment Variables"
echo "------------------------------------"
echo "e1 = "$e1
echo "e2 = "$e2
sh test2

test2 script: (copy below)

# test2 environment variable script
echo "Test 2 Program Environment Variables"
echo "----------------------------"
echo "e1 = "$e1
echo "e2 = "$e2

Output would look like this:
cjones@chris:~$ sh test1
Test 1 Program Environment Variables
e1 = non-exported variable
e2 = exported variable
Test 2 Program Environment Variables
e1 =
e2 = exported variable

Happy computing


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
setting JAVA_HOME gauravbagga Linux - Newbie 2 03-04-2005 10:17 PM
JAVA_HOME Variable yea420 Linux - Software 6 08-29-2004 07:37 PM
PATH and JAVA_HOME peteABK Linux - Newbie 4 10-19-2003 05:30 PM
$JAVA_HOME and $PATH magnum818 Linux - Software 2 09-30-2003 11:05 PM
postgres and setting the environment for PGDATA squadja Linux - Newbie 1 08-13-2003 03:28 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:46 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration