about environmental variables
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=
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
|
#1 |
run:
gedit ~/.bashrc
add the line:
export JAVA_HOME=
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
|
#2 |
sir what is JAVA_HOME and the why the path is like "
/usr/jaa/
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:/
>
> Status: Open => Answered
>
> actionparsnip proposed the following answer:
> run:
>
> gedit ~/.bashrc
>
> add the line:
>
> export JAVA_HOME=
>
> 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:/
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https:/
>
> You received this question notification because you asked the question.
>
Revision history for this message
|
#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://
Revision history for this message
|
#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=
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:/
>
> 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://
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https:/
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https:/
>
> You received this question notification because you asked the question.
>
Revision history for this message
|
#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/
Thanks
Revision history for this message
|
#6 |
the out put is like this
ramu@ramki:~$ file /usr/java/
/usr/java/
`/usr/java/
On Fri, May 20, 2011 at 2:36 PM, actionparsnip <
<email address hidden>> wrote:
> Your question #158299 on Ubuntu changed:
> https:/
>
> 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/
>
> Thanks
>
> --
> To answer this request for more information, you can either reply to
> this email or enter your reply at the following page:
> https:/
>
> You received this question notification because you asked the question.
>
Revision history for this message
|
#7 |
If you installed the openjdk then you should set JAVA_HOME as /usr/lib/
If you installed a different jdk then you need to let us know which one.
Revision history for this message
|
#8 |
sorry /usr/lib/
Revision history for this message
|
#9 |
i am installed a different jdk which is from java.sun.com and the file name
is
jdk-6u25-
On Fri, May 20, 2011 at 3:05 PM, Smitten <
<email address hidden>> wrote:
> Your question #158299 on Ubuntu changed:
> https:/
>
> Status: Open => Answered
>
> Smitten proposed the following answer:
> If you installed the openjdk then you should set JAVA_HOME as
> /usr/lib/
> 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:/
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https:/
>
> You received this question notification because you asked the question.
>
Revision history for this message
|
#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
|
#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-
On Fri, May 20, 2011 at 3:20 PM, Manfred Hampl <
<email address hidden>> wrote:
> Your question #158299 on Ubuntu changed:
> https:/
>
> 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:/
>
> You received this question notification because you asked the question.
>
Revision history for this message
|
#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=
Maybe you need also to add the line
PATH=$JAVA_
Revision history for this message
|
#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:/
>
> 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=
>
> Maybe you need also to add the line
>
> PATH=$JAVA_
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https:/
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https:/
>
> You received this question notification because you asked the question.
>
Revision history for this message
|
#14 |
sir why are you not replying me and how can i add the following line
export JAVA_HOME=
to ~/.bashrc file
and how can add to this PATH=$JAVA_
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:/
>
> 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:/
> >
> > 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=
> >
> > Maybe you need also to add the line
> >
> > PATH=$JAVA_
> >
> > --
> > If this answers your question, please go to the following page to let us
> > know that it is solved:
> >
> https:/
> >
> > If you still need help, you can reply to this email or go to the
> > following page to enter your feedback:
> > https:/
> >
> > 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
|
#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
|
#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
|
#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@ramki:~$ PATH=$PATH:$JAVA
ramu@ramki:~$ printenv PATH
/usr/local/
/home/ramu/
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:/
>
> Project: gnome-terminal in Ubuntu => bash in Ubuntu
>
> --
> You received this question notification because you asked the question.
>
Revision history for this message
|
#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
|
#19 |
If that stuff works then run:
gedit ~/.bashrc
add the lines:
export JAVA=/home/
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
|
#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:/
>
> Status: Needs information => Answered
>
> actionparsnip proposed the following answer:
> If that stuff works then run:
>
> gedit ~/.bashrc
>
> add the lines:
>
> export JAVA=/home/
> 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:/
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https:/
>
> You received this question notification because you asked the question.
>
Revision history for this message
|
#21 |
It's a text file and I gave the 2 lines to add....how is that hard?
Revision history for this message
|
#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:
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/
/home/ramu/
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:/
>
> Status: Needs information => Answered
>
> actionparsnip proposed the following answer:
> If that stuff works then run:
>
> gedit ~/.bashrc
>
> add the lines:
>
> export JAVA=/home/
> 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:/
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https:/
>
> You received this question notification because you asked the question.
>
Revision history for this message
|
#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:/
>
> 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:/
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https:/
>
> You received this question notification because you asked the question.
>
Revision history for this message
|
#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:/
>
> 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:/
> >
> > 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:/
> >
> > If you still need help, you can reply to this email or go to the
> > following page to enter your feedback:
> > https:/
> >
> > 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
|
#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
|
#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/
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/
/home/ramu/
/home/ramu/
/home/ramu/
/home/ramu/
/home/ramu/
/home/ramu/
/home/ramu/
/home/ramu/
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:/
>
> 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:/
>
> You received this question notification because you asked the question.
>
Revision history for this message
|
#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
|
#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
|
#29 |
sir the out put is like
ramu@ramki:~$ find ~ -name javac -print
/home/ramu/
/home/ramu/
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:/
>
> 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:/
>
> You received this question notification because you asked the question.
>
Revision history for this message
|
#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=
PATH=$JAVA_
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
|
#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:/
>
> 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=
> PATH=$JAVA_
>
> 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:/
>
> You received this question notification because you asked the question.
>
Revision history for this message
|
#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
|
#33 |
As one can see in http://
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=$
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=
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.