about environmental variables

Asked by prasad.ram

hi sir i am learning java for that i download 32 bit jdk for ubuntu 10.10 next set up environmental variables my doubt is what are environmental variables and how to set it in net some body said that "export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java"
and some body said that set dotbashrc to java/bin so please tell me what should i do

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu bash Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

run:

gedit ~/.bashrc

add the line:

export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java

To the bottom, close gedit, then run:

source ~/.bashrc

and it will apply to the current terminal, and every other terminal you use

Revision history for this message
prasad.ram (prasad-ram126) said :
#2

sir what is JAVA_HOME and the why the path is like "
/usr/jaa/jdk1.5.0_07/bin/java"
and please explain environmental variables and please send me syntax of
export command

On Fri, May 20, 2011 at 1:21 PM, actionparsnip <
<email address hidden>> wrote:

> Your question #158299 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/158299
>
> Status: Open => Answered
>
> actionparsnip proposed the following answer:
> run:
>
> gedit ~/.bashrc
>
> add the line:
>
> export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java
>
> To the bottom, close gedit, then run:
>
> source ~/.bashrc
>
> and it will apply to the current terminal, and every other terminal you
> use
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/ubuntu/+question/158299/+confirm?answer_id=0
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+question/158299
>
> You received this question notification because you asked the question.
>

Revision history for this message
Smitten (simon-booth) said :
#3

JAVA_HOME is the variable which other java apps will use to find the java runtimes.

It is a broad subject - I suggest you start here http://en.wikipedia.org/wiki/Environment_variable

Revision history for this message
prasad.ram (prasad-ram126) said :
#4

is JAVA_HOME a folder if it is folder where can find it in my system in
Internet somebody said that set the variables to like "export
dot.bashrc=/home/ramu/java/jdk1.6.0_25/bin"
is it correct i don't know this so please tell me with detail

On Fri, May 20, 2011 at 2:01 PM, Smitten <
<email address hidden>> wrote:

> Your question #158299 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/158299
>
> Status: Open => Answered
>
> Smitten proposed the following answer:
> JAVA_HOME is the variable which other java apps will use to find the
> java runtimes.
>
> It is a broad subject - I suggest you start here
> http://en.wikipedia.org/wiki/Environment_variable
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/ubuntu/+question/158299/+confirm?answer_id=2
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+question/158299
>
> You received this question notification because you asked the question.
>

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#5

dot.bashrc makes no sense, if you run:

cd; la

you will see the file:

.bashrc

which is where you are adding the text.

Can you give the output of:

file /usr/java/jdk1.5.0_07/bin/java

Thanks

Revision history for this message
prasad.ram (prasad-ram126) said :
#6

the out put is like this
ramu@ramki:~$ file /usr/java/jdk1.5.0_07/bin/java
/usr/java/jdk1.5.0_07/bin/java: ERROR: cannot open
`/usr/java/jdk1.5.0_07/bin/java' (No such file or directory)"

On Fri, May 20, 2011 at 2:36 PM, actionparsnip <
<email address hidden>> wrote:

> Your question #158299 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/158299
>
> Status: Open => Needs information
>
> actionparsnip requested more information:
> dot.bashrc makes no sense, if you run:
>
> cd; la
>
> you will see the file:
>
> .bashrc
>
> which is where you are adding the text.
>
> Can you give the output of:
>
> file /usr/java/jdk1.5.0_07/bin/java
>
> Thanks
>
> --
> To answer this request for more information, you can either reply to
> this email or enter your reply at the following page:
> https://answers.launchpad.net/ubuntu/+question/158299
>
> You received this question notification because you asked the question.
>

Revision history for this message
Smitten (simon-booth) said :
#7

If you installed the openjdk then you should set JAVA_HOME as /usr/lib/jvm/java-6-openjdk
If you installed a different jdk then you need to let us know which one.

Revision history for this message
Smitten (simon-booth) said :
#8

sorry /usr/lib/jvm/java-6-openjdk/bin

Revision history for this message
prasad.ram (prasad-ram126) said :
#9

i am installed a different jdk which is from java.sun.com and the file name
is
jdk-6u25-linux-i586.bin

On Fri, May 20, 2011 at 3:05 PM, Smitten <
<email address hidden>> wrote:

> Your question #158299 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/158299
>
> Status: Open => Answered
>
> Smitten proposed the following answer:
> If you installed the openjdk then you should set JAVA_HOME as
> /usr/lib/jvm/java-6-openjdk
> If you installed a different jdk then you need to let us know which one.
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/ubuntu/+question/158299/+confirm?answer_id=6
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+question/158299
>
> You received this question notification because you asked the question.
>

Revision history for this message
Manfred Hampl (m-hampl) said :
#10

execute the following commands and copy/paste the output

ls -la /usr/java
ls -la /usr/lib/jvm
ls -la ~/java

Revision history for this message
prasad.ram (prasad-ram126) said :
#11

the out put is

ramu@ramki:~$ ls -la /usr/java
ls: cannot access /usr/java: No such file or directory
ramu@ramki:~$ ls -la /usr/lib/java
ls: cannot access /usr/lib/java: No such file or directory
ramu@ramki:~$ ls -la ~/java
total 83076
drwxr-xr-x 3 ramu ramu 4096 2011-05-18 22:07 .
drwxr-xr-x 49 ramu ramu 4096 2011-05-20 14:48 ..
drwxr-xr-x 10 ramu ramu 4096 2011-05-18 22:08 jdk1.6.0_25
-rwxr-xr-x 1 ramu ramu 85052342 2011-05-18 17:18 jdk-6u25-linux-i586.bin

On Fri, May 20, 2011 at 3:20 PM, Manfred Hampl <
<email address hidden>> wrote:

> Your question #158299 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/158299
>
> Status: Open => Needs information
>
> Manfred Hampl requested more information:
> execute the following commands and copy/paste the output
>
> ls -la /usr/java
> ls -la /usr/lib/jvm
> ls -la ~/java
>
> --
> To answer this request for more information, you can either reply to
> this email or enter your reply at the following page:
> https://answers.launchpad.net/ubuntu/+question/158299
>
> You received this question notification because you asked the question.
>

Revision history for this message
Best Manfred Hampl (m-hampl) said :
#12

It seems to me that you have installed your java package below ~/java
So I assume you need to add the following line to your ~/.bashrc file:

export JAVA_HOME=/home/ramu/java/jdk1.6.0_25/

Maybe you need also to add the line

PATH=$JAVA_HOME/bin:$PATH

Revision history for this message
prasad.ram (prasad-ram126) said :
#13

sir i did not understand what should i do and why please explain such that i
can do my own when ever it require

On Fri, May 20, 2011 at 3:55 PM, Manfred Hampl <
<email address hidden>> wrote:

> Your question #158299 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/158299
>
> Status: Open => Answered
>
> Manfred Hampl proposed the following answer:
> It seems to me that you have installed your java package below ~/java
> So I assume you need to add the following line to your ~/.bashrc file:
>
> export JAVA_HOME=/home/ramu/java/jdk1.6.0_25/
>
> Maybe you need also to add the line
>
> PATH=$JAVA_HOME/bin:$PATH
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/ubuntu/+question/158299/+confirm?answer_id=11
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+question/158299
>
> You received this question notification because you asked the question.
>

Revision history for this message
prasad.ram (prasad-ram126) said :
#14

sir why are you not replying me and how can i add the following line
export JAVA_HOME=/home/ramu/java/jdk1.6.0_25/
to ~/.bashrc file
and how can add to this PATH=$JAVA_HOME/bin:$PATH also
please tell me sir i did not know and reply me as soon as possible

On Fri, May 20, 2011 at 4:01 PM, prasad.ram <
<email address hidden>> wrote:

> Your question #158299 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/158299
>
> Status: Answered => Open
>
> You are still having a problem:
> sir i did not understand what should i do and why please explain such that
> i
> can do my own when ever it require
>
> On Fri, May 20, 2011 at 3:55 PM, Manfred Hampl <
> <email address hidden>> wrote:
>
> > Your question #158299 on Ubuntu changed:
> > https://answers.launchpad.net/ubuntu/+question/158299
> >
> > Status: Open => Answered
> >
> > Manfred Hampl proposed the following answer:
> > It seems to me that you have installed your java package below ~/java
> > So I assume you need to add the following line to your ~/.bashrc file:
> >
> > export JAVA_HOME=/home/ramu/java/jdk1.6.0_25/
> >
> > Maybe you need also to add the line
> >
> > PATH=$JAVA_HOME/bin:$PATH
> >
> > --
> > If this answers your question, please go to the following page to let us
> > know that it is solved:
> >
> https://answers.launchpad.net/ubuntu/+question/158299/+confirm?answer_id=11
> >
> > If you still need help, you can reply to this email or go to the
> > following page to enter your feedback:
> > https://answers.launchpad.net/ubuntu/+question/158299
> >
> > You received this question notification because you asked the question.
> >
>
> --
> You received this question notification because you asked the question.
>

Revision history for this message
mycae (mycae) said :
#15

Prasad:

You are going to have to do some work for yourself. Go to google, or other favourite search engine, then type (without quotes) "How to edit bashrc"; try adding in a few terms to generate alternate searches, like "ubuntu" or "JAVA_HOME" or whatever.

Short answer, use nautilus, with show hidden files, then use a text editor.

Revision history for this message
mycae (mycae) said :
#16

Also, someone not replying in 4 hours probably means they are asleep! This is not a chat session -- you may need patience to get a reply.

Revision history for this message
prasad.ram (prasad-ram126) said :
#17

sir i try a little but the environmental variables is set for that terminal
only and the commands are like

ramu@ramki:~$ export JAVA=/home/ramu/java/jdk1.6.0_25/bin
ramu@ramki:~$ PATH=$PATH:$JAVA
ramu@ramki:~$ printenv PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:*
/home/ramu/java/jdk1.6.0_25/bin*

and the above bold letters are my path so how can i add this path
permanently?
please help me sir

On Sat, May 21, 2011 at 7:31 AM, marcobra (Marco Braida) <
<email address hidden>> wrote:

> Your question #158299 on bash in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> Project: gnome-terminal in Ubuntu => bash in Ubuntu
>
> --
> You received this question notification because you asked the question.
>

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#18

ok lets do this the long but easy way. What is the output of:

sudo find / -iname jave | grep bin

The command may take a while to run, when the prompt reappears, copy the output and paste as an update

Thanks

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#19

If that stuff works then run:

gedit ~/.bashrc

add the lines:

export JAVA=/home/ramu/java/jdk1.6.0_25/bin
export PATH=$PATH:$JAVA

to the BOTTOM of the file, save the new file, close gedit and run:

source ~/.bashrc

The variables are now set and will apply all the time.

Revision history for this message
prasad.ram (prasad-ram126) said :
#20

how can add the line because the file (.bashrc)is in shell program with out
knowing the syntax of it how can i add these lines is there any method if
not then try to explain me how to add in shell script

On Sat, May 21, 2011 at 4:15 PM, actionparsnip <
<email address hidden>> wrote:

> Your question #158299 on bash in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> Status: Needs information => Answered
>
> actionparsnip proposed the following answer:
> If that stuff works then run:
>
> gedit ~/.bashrc
>
> add the lines:
>
> export JAVA=/home/ramu/java/jdk1.6.0_25/bin
> export PATH=$PATH:$JAVA
>
> to the BOTTOM of the file, save the new file, close gedit and run:
>
> source ~/.bashrc
>
> The variables are now set and will apply all the time.
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
>
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299/+confirm?answer_id=18
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> You received this question notification because you asked the question.
>

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#21

It's a text file and I gave the 2 lines to add....how is that hard?

Revision history for this message
prasad.ram (prasad-ram126) said :
#22

i did not give any out put

ramu@ramki:~$ sudo find / -iname jave | grep bin
[sudo] password for ramu:
ramu is not in the sudoers file. This incident will be reported.
ramu@ramki:~$ su admin
Password:
su: Authentication failure
ramu@ramki:~$ su admin
Password:
admin@ramki:/home/ramu$ cd
admin@ramki:~$ sudo find / -iname jave | grep bin
[sudo] password for admin:
admin@ramki:~$
ramu is not a sudo user so login as a administrator and run the command but
it
then i search the command in that you send me a mistake i.e jave for java
then i changed
it then the out put is like this

admin@ramki:~$ sudo find / -iname java | grep bin
/home/ramu/java/jdk1.6.0_25/jre/*bin*/java
/home/ramu/java/jdk1.6.0_25/*bin*/java
so please send me what can i do

On Sat, May 21, 2011 at 4:15 PM, actionparsnip <
<email address hidden>> wrote:

> Your question #158299 on bash in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> Status: Needs information => Answered
>
> actionparsnip proposed the following answer:
> If that stuff works then run:
>
> gedit ~/.bashrc
>
> add the lines:
>
> export JAVA=/home/ramu/java/jdk1.6.0_25/bin
> export PATH=$PATH:$JAVA
>
> to the BOTTOM of the file, save the new file, close gedit and run:
>
> source ~/.bashrc
>
> The variables are now set and will apply all the time.
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
>
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299/+confirm?answer_id=18
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> You received this question notification because you asked the question.
>

Revision history for this message
prasad.ram (prasad-ram126) said :
#23

because at the end it end with if if you add then it doesn't execute
because these lines are not in the shell script

On Sat, May 21, 2011 at 4:51 PM, actionparsnip <
<email address hidden>> wrote:

> Your question #158299 on bash in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> Status: Open => Answered
>
> actionparsnip proposed the following answer:
> It's a text file and I gave the 2 lines to add....how is that hard?
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
>
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299/+confirm?answer_id=20
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> You received this question notification because you asked the question.
>

Revision history for this message
prasad.ram (prasad-ram126) said :
#24

sir i add what you above and i saved also and then i run the command
source ~./bashrc
but of no use it is still not adding
if i compile a program it gives like

ramu@ramki:~/pjava$ javac HelloWorld.java
The program 'javac' can be found in the following packages:
 * openjdk-6-jdk
 * ecj
 * gcj-4.4-jdk
 * gcj-4.5-jdk
Ask your administrator to install one of them
and already said that it is in shell script so doesn't works but you opposed
me

On Sat, May 21, 2011 at 5:01 PM, prasad.ram <
<email address hidden>> wrote:

> Your question #158299 on bash in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> You gave more information on the question:
> because at the end it end with if if you add then it doesn't execute
> because these lines are not in the shell script
>
> On Sat, May 21, 2011 at 4:51 PM, actionparsnip <
> <email address hidden>> wrote:
>
> > Your question #158299 on bash in Ubuntu changed:
> > https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
> >
> > Status: Open => Answered
> >
> > actionparsnip proposed the following answer:
> > It's a text file and I gave the 2 lines to add....how is that hard?
> >
> > --
> > If this answers your question, please go to the following page to let us
> > know that it is solved:
> >
> >
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299/+confirm?answer_id=20
> >
> > If you still need help, you can reply to this email or go to the
> > following page to enter your feedback:
> > https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
> >
> > You received this question notification because you asked the question.
> >
>
> --
> You received this question notification because you asked the question.
>

Revision history for this message
Manfred Hampl (m-hampl) said :
#25

Hi prasad.ram! Sorry that i could not continue yesterday, but I had other things to do. I am answering questions like yours in my free time without getting paid for it, so I can dedicate only limited capacity to such activities. And I hoped that someone else might pick your question up and continue - which was the case.

There seem to be different information whether a value for JAVA or for JAVA_HOME has to be added to .bashrc

please execute the following command and paste the output

find ~ -name java* -print

Revision history for this message
prasad.ram (prasad-ram126) said :
#26

thank you for responding me sir and i am struggling me with this a lot then
i set to a single terminal by these commands
export JAVA=/home/ramu/java/jdk1.6.0_25/bin
PATH=$PATH:$JAVA
 but it is do for every time when i am open a terminal please tell me
permanently and the out put for which you said the command is like
 ramu@ramki:~$ find ~ -name java* -print
/home/ramu/java
/home/ramu/java/jdk1.6.0_25/jre/bin/java
/home/ramu/java/jdk1.6.0_25/bin/java
/home/ramu/java/jdk1.6.0_25/src/java
/home/ramu/java/jdk1.6.0_25/src/com/sun/java
/home/ramu/java/jdk1.6.0_25/src/org/omg/stub/java
/home/ramu/java/jdk1.6.0_25/db/demo/programs/vtis/java
/home/ramu/java/jdk1.6.0_25/db/demo/programs/scores/java
/home/ramu/matlab/win32/java
/home/ramu/matlab/win64/java
ramu@ramki:~$
 sir please help me

On Sat, May 21, 2011 at 6:05 PM, Manfred Hampl <
<email address hidden>> wrote:

> Your question #158299 on bash in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> Status: Open => Needs information
>
> Manfred Hampl requested more information:
> Hi prasad.ram! Sorry that i could not continue yesterday, but I had
> other things to do. I am answering questions like yours in my free time
> without getting paid for it, so I can dedicate only limited capacity to
> such activities. And I hoped that someone else might pick your question
> up and continue - which was the case.
>
> There seem to be different information whether a value for JAVA or for
> JAVA_HOME has to be added to .bashrc
>
> please execute the following command and paste the output
>
> find ~ -name java* -print
>
> --
> To answer this request for more information, you can either reply to
> this email or enter your reply at the following page:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> You received this question notification because you asked the question.
>

Revision history for this message
Manfred Hampl (m-hampl) said :
#27

I ma rather sure thaht there will be a solution for your java problem.

Please issue also the following command and copy/paste the output.

find ~ -name javac -print

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#28

If you add the lines to bashrc it gets executed just like the rest, that is what that file is for. If the lines are in the file, they get executed, the location in the file is moot. Bottom is just a handy way of knowing the things YOU added to help with troubleshooting. They ARE in the script as they are IN the file, it's that simple.

Revision history for this message
prasad.ram (prasad-ram126) said :
#29

sir the out put is like
ramu@ramki:~$ find ~ -name javac -print
/home/ramu/java/jdk1.6.0_25/sample/javac
/home/ramu/java/jdk1.6.0_25/bin/javac
ramu@ramki:~$

On Sat, May 21, 2011 at 6:31 PM, Manfred Hampl <
<email address hidden>> wrote:

> Your question #158299 on bash in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> Status: Open => Needs information
>
> Manfred Hampl requested more information:
> I ma rather sure thaht there will be a solution for your java problem.
>
> Please issue also the following command and copy/paste the output.
>
> find ~ -name javac -print
>
> --
> To answer this request for more information, you can either reply to
> this email or enter your reply at the following page:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> You received this question notification because you asked the question.
>

Revision history for this message
Manfred Hampl (m-hampl) said :
#30

OK, I think we have seen all we need. I will try to explain all steps as clear as possible.

You have to add two lines to your .bashrc file.

Comments:
You have to note that normally in the nautilus file explorer you cannot see that file. Only if you open nautilus and press ctrl-H you will also see all 'hidden' files (those with a filename that starts with a dot).
The contents of the .bashrc are rather cryptic, don't worry, you need not understand their meaning.

1. open a terminal

2. issue the command
gedit ~/.bashrc
This will open an edit window with the current contents of your .bashrc file loaded

3. Naviagate to the end of that file

4. Add the following two lines:

export JAVA_HOME=/home/ramu/java/jdk1.6.0_25
PATH=$JAVA_HOME/bin:$PATH

5. If there is already a line starting with "export JAVA_HOME" from a previous editing attempt, remove that one
If there is already a line with "PATH" and "$JAVA" from a previous editing attempt, remove that one also

6. save the file and close the editor

7. Log off and log on again to mage sure that the new .bashrc file is correctly activated

8. open a terminal and excute the following two commands:

java -version
javac -version

If these commands show your java version we have success, if not please provide the output of the following commands:

echo $PATH
echo $JAVA_HOME
which java
which javac

Revision history for this message
prasad.ram (prasad-ram126) said :
#31

Thank you sir it works but i have a few doubts if ur free please explain is
JAVA_HOME is a folder what is this and next one In the path you didn't add
bin how can it implicitly add to our PATH and last the .bashrc file is in
shell script but our two lines are not in shell scripts so how it works ?
If possible please explain ? once again thank you very much sir( Manfred
Hampl )

On Sat, May 21, 2011 at 7:20 PM, Manfred Hampl <
<email address hidden>> wrote:

> Your question #158299 on bash in Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> Status: Open => Needs information
>
> Manfred Hampl requested more information:
> OK, I think we have seen all we need. I will try to explain all steps as
> clear as possible.
>
> You have to add two lines to your .bashrc file.
>
> Comments:
> You have to note that normally in the nautilus file explorer you cannot see
> that file. Only if you open nautilus and press ctrl-H you will also see all
> 'hidden' files (those with a filename that starts with a dot).
> The contents of the .bashrc are rather cryptic, don't worry, you need not
> understand their meaning.
>
> 1. open a terminal
>
> 2. issue the command
> gedit ~/.bashrc
> This will open an edit window with the current contents of your .bashrc
> file loaded
>
> 3. Naviagate to the end of that file
>
> 4. Add the following two lines:
>
> export JAVA_HOME=/home/ramu/java/jdk1.6.0_25
> PATH=$JAVA_HOME/bin:$PATH
>
> 5. If there is already a line starting with "export JAVA_HOME" from a
> previous editing attempt, remove that one
> If there is already a line with "PATH" and "$JAVA" from a previous editing
> attempt, remove that one also
>
> 6. save the file and close the editor
>
> 7. Log off and log on again to mage sure that the new .bashrc file is
> correctly activated
>
> 8. open a terminal and excute the following two commands:
>
> java -version
> javac -version
>
> If these commands show your java version we have success, if not please
> provide the output of the following commands:
>
> echo $PATH
> echo $JAVA_HOME
> which java
> which javac
>
> --
> To answer this request for more information, you can either reply to
> this email or enter your reply at the following page:
> https://answers.launchpad.net/ubuntu/+source/bash/+question/158299
>
> You received this question notification because you asked the question.
>

Revision history for this message
prasad.ram (prasad-ram126) said :
#32

thak you sir for giving me nice information and explanation of him(Manfred Hampl )
and i am very much thanking to him

Revision history for this message
Manfred Hampl (m-hampl) said :
#33

As one can see in http://download.oracle.com/javase/6/docs/technotes/tools/linux/jdkfiles.html there is a directory tree containing several different java related files. The java environment needs to know where this tree is located (via the JAVA_HOME environment variable pointing to the top of that tree).

In the subdirectory "bin" of that tree (the leftmost in the picture) there are the executable programs java and javac.

On Unix when you issue a command like 'java' the command interpreter checks if it is a unix shell builtin command (which it isn't), and then looks in each part of the PATH environment variable, if there is an executable file with that name in the one of the directories that are listed in the PATH variable.

The .bashrc command "PATH=$JAVA_HOME/bin:$PATH" instructs the shell to change the PATH variable by including the java bin directory. The command means something like "Take the current contents of the JAVA_HOME variable and append /bin to that string; append a ":" character to that (which is the separation character for the different directories in the PATH value), and then append the current contents of the PATH variable to that, and finally put what you got as new value into the PATH environment variable.

And finally you have to know that .bashrc is a shell script that is executed whenever you start a terminal, or when any other program starts a script. So putting the two lines there makes sure that the contents are available for all programs that need them, without the need to issue a JAVA_PATH=... command manually.

You just have to be aware that when you upgrade your java system to a higher version you have to update your .bashrc file, e.g. if you update jdk from version 1.6.0_25 to 1.6.0_26, you have to change the JAVA_HOME line in your .bashrc from export JAVA_HOME=/home/ramu/java/jdk1.6.0_25 to export JAVA_HOME=/home/ramu/java/jdk1.6.0_26 or whatever the new version and its directory will then be.

If you need more information about shell script programming and environment variables, or about java, please try to find information on the internet or in a library.

By the way, don't expect more answers from me today; I am going to stop now.