LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-03-2006, 01:42 PM   #1
mharris45
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
and
#: export JAVA_HOME=/usr/java
and
#:
PATH=/usr/java/:$PATH

Could somebody help clear this up please?
 
Old 03-03-2006, 11:32 PM   #2
JoseVilla
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, 09:49 AM   #3
mharris45
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, 06:35 PM   #4
JoseVilla
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, 07:25 PM   #5
docalton
Member
 
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
cjones@chris:~$

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
 
  


Reply



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 09:17 PM
JAVA_HOME Variable yea420 Linux - Software 6 08-29-2004 06:37 PM
PATH and JAVA_HOME peteABK Linux - Newbie 4 10-19-2003 04:30 PM
$JAVA_HOME and $PATH magnum818 Linux - Software 2 09-30-2003 10:05 PM
postgres and setting the environment for PGDATA squadja Linux - Newbie 1 08-13-2003 02:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:31 PM.

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