How to Set JAVA_HOME _ PATH Variables Under Linux Bash Profile
-
Upload
prakash9565 -
Category
Documents
-
view
192 -
download
0
description
Transcript of How to Set JAVA_HOME _ PATH Variables Under Linux Bash Profile
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 1/20
TutorialsBASH ShellTroubleshootingNginxNetworkingMySQLGoogle Cloud PlatformAmazon Cloud ComputingRackspace Cloud ComputingLinux
CentOSDebian / UbuntuUbuntu LinuxSuseRedHat and FriendsSlackware Linux
UNIXAIXMac OS XFreeBSDFreeBSD Jails (VPS)OpenbsdSolaris
See all tutorial topicsBlogAboutContact usForumLinux Scripting GuideRSS/FEED
Linux FAQ / Howtos
How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
by Nix Craft on October 10, 2007 74 comments LAST UPDATED May 25, 2012
in BASH Shell, CentOS, Debian / Ubuntu
I just need a help to show me how to setup java path on Linux. How can I set JAVA_HOME and PATH variables for every user under my Linux system?
~/.bash_profile is a startup script which generally runs once. This particular file is used for commands which run when the normal user logs in. Common uses for .bash_profile are to set environment variablessuch as PATH, JAVA_HOME, to create aliases for shell commands, and to set the default permissions for newly created files.
Set JAVA_HOME / PATH for a single user
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 2/20
Login to your account and open .bash_profile file$ vi ~/.bash_profile
Set JAVA_HOME as follows using syntax export JAVA_HOME=. If your path is set to /usr/java/jdk1.5.0_07/bin/java, set it as follows:export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java
Set PATH as follows:export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
Feel free to replace /usr/java/jdk1.5.0_07 as per your setup. Save and close the file. Just logout and login back to see new changes. Alternatively, type the following command to activate the new path settings immediately:$ source ~/.bash_profile
OR$ . ~/.bash_profile
Verify new settings:$ echo $JAVA_HOME
$ echo $PATH
Tip: Use the following command to find out exact path to which java executable under UNIX / Linux:$ which java
Please note that the file ~/.bashrc is similar, with the exception that ~/.bash_profile runs only for Bash login shells and .bashrc runs for every new Bash shell.
Set JAVA_HOME / PATH for all user
You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:# vi /etc/profile
Next setup PATH / JAVA_PATH variables as follows:export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
Save and close the file. Once again you need to type the following command to activate the path settings immediately:# source /etc/profile
OR# . /etc/profile
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!Featured Articles:
30 Cool Open Source Software I Discovered in 2013 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS XTop 30 Nmap Command Examples For Sys/Network Admins25 PHP Security Best Practices For Sys Admins20 Linux System Monitoring Tools Every SysAdmin Should Know20 Linux Server Hardening Security TipsLinux: 20 Iptables Examples For New SysAdminsTop 20 OpenSSH Server Best Security PracticesTop 20 Nginx WebServer Best Security Practices20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors15 Greatest Open Source Terminal Applications Of 2012My 10 UNIX Command Line MistakesTop 10 Open Source Web-Based Project Management SoftwareTop 5 Email Client For Linux, Mac OS X, and Windows UsersThe Novice Guide To Buying A Linux Laptop
{ 74 comments read them below or add one }
1 dino November 13, 2007 at 5:23 am
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 3/20
I believe this is wrong !
1) In my case I did all you said for .bash_profile, however, running which java still shows old java path (crappy java that comes with linux fedora 7)
2) I tried the same to set /etc/profile but I believe you provided wrong sintax
Could somebody provide correct sintax for seting java path in /etc/profile or whatever as long as my which java will show my newest java?
Thanks
Reply
2 Bijudas Porathur March 19, 2012 at 1:54 pm
The correct syntax is as show below,
export PATH=/usr/java/jdk1.7.0_03/bin:$PATH
Reply
3 Mustafa Buljubasic November 13, 2007 at 5:44 am
I have read lots of user posting at various pages and none of them would work. Finally, I found a way to do this correctly and hope this will help to some of you.
Follow the simple steps:
1. To set the environment variables :
echo export JAVA_HOME=/opt/jdk1.5.0_12 > /etc/profile.d/jdk.shecho export PATH=$JAVA_HOME/bin:$PATH >> /etc/profile.d/jdk.sh
2. You have to source the file you just created by typing:source /etc/profile.d/jdk.sh
3. Test if Java environment is successfully installed by typing in this in the shell:java -version
Reply
4 NAVEEN SHARMA December 15, 2010 at 4:21 pm
when I type these above script or command my terminal say Permission denied.Tell the answerThanks in Advnace
Reply
5 Chandrasekar February 16, 2011 at 6:57 am
use sudo if youre using ubuntu.else try using suTry googling in case both dont work :D
Reply
6 Sreenivasa Reddy Mulinti March 23, 2014 at 5:03 am
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 4/20
Hi Mustafa,
Thank you for solution. This worked perfectly for me in Linux.
Reply
7 Mustafa Buljubasic November 13, 2007 at 6:03 am
I have read lots of posting and none of them worked well. This one did so I decided to try to post it hopefully somebody else wont have to get this frustrated to get such a simple thing done.
1. To set the environment variables:
echo export JAVA_HOME=/opt/jdk1.5.0_12 > /etc/profile.d/jdk.shecho export PATH=$JAVA_HOME/bin:$PATH >> /etc/profile.d/jdk.sh
2. You have to source the file you just created by typing:source /etc/profile.d/jdk.sh
3. Test if Java environment is successfully installed by typing in this in the shell:$ java -versionjava version 1.6.0_03Java(TM) SE Runtime Environment (build 1.6.0_03-b05)Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)
You can also use which java to test:$ which java/usr/java/jdk1.6.0_03/bin/java
Reply
8 sandeep February 2, 2011 at 8:59 am
hay it is workingbut how can i set permentally setthe java pathits working only one terminoal onlyi need permentally java path settinghelp me
Reply
9 ashwin February 25, 2011 at 8:09 am
Hi Sandeep,
Setting java class path in Linux:I have faced the same problem . How to set it permanently. please help me
Reply
10 csr June 3, 2011 at 7:15 am
+1 Made my day. Thank you.
Reply
11 Mustafa Buljubasic November 13, 2007 at 6:11 am
my last reply is using mistakenly 2 different versions of jdk. Reference to jdk in point 1 and 3 should be the same as well as in the testing part
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 5/20
Reply
12 Mustafa Buljubasic November 13, 2007 at 6:16 am
My last 2 postings use 2 different jdk by accident. References to jdk should be the same.
For the sake of consistance, please use (of course substitute your java directory in place of mine /usr/lib/java/jdk.):echo export JAVA_HOME=/usr/lib/java/jdk1.6.0_03 > /etc/profile.d/jdk.shistead ofecho export JAVA_HOME=/opt/jdk1.5.0_12 > /etc/profile.d/jdk.sh
My appologies.
Reply
13 CamNhung September 27, 2010 at 4:06 am
at the terminal. You type 2 comand to apply the env for bath shell.#source /etc/profile#/etc/init.d/x11-common restart
Reply
14 Ado January 29, 2008 at 9:21 am
Mustafa-pasa,
bas se nesto gnjavim sa serverom ali ovaj tvoj post je dosao ko kec na desetku.
Thanks for your post, it does exactly what it says on the tin. Just what I needed.
Reply
15 mohammed February 18, 2008 at 12:35 am
I use the IDE 6 with netbeans to create a simple application and I build it and when I navigate to its dist location through the terminal and type:>> java -jar addition.jarit gives me this message could you please help me to solve this problem:Exception in thread main java.lang.NoClassDefFoundError: javax/swing/GroupLayout$Group
Reply
16 ash April 24, 2008 at 10:34 am
i need to run my application with jdk,jmf and jakarta tomcat hw do i go about setting the environment variables?
Reply
17 rupert June 13, 2008 at 10:39 pm
I think its worth mentioning that on most Linux systems, there is a convenient facility to manage different java implementations its called alternatives depending on the version of your system it may be:/usr/sbin/alternatives config javaorsudo update-alternatives config java
Reply
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 6/20
18 rupert June 14, 2008 at 12:25 am
Rather than log out and back in you can run your new bash profile with a single period:$ cd$ . .bash_profile
Reply
19 Mustafa Buljubasic December 14, 2008 at 7:49 pm
How to install JDK (Java Development Kit) on Linux, In my case Fedora 10?
1. Log in as root:su-type in your password and the prompt will change from $: to #:
2. Download JDK from here:http://java.sun.com/javase/downloads/index.jspAs of time of this post, the most current JDK was:Java SE Development Kit (JDK) 6 Update 11.Select file jdk-6u11-linux-i586.rpm.bin to download it by providing your operation system and multilanguage.
3. Go to directory where you downloaded the file (In my case it is Download directory in /home/username/Download/)The file is called jdk-6u11-linux-i586.rpm.bin
4. Change mode of this file so you can execute it by issuing:chmod 755 jdk-6u11-linux-i586.rpm.bin
5. run the file by issuing:./jdk-6u11-linux-i586.rpm.bin
This will show acceptance agreement, press untill you reach end they type yes and press and the installation will start.
6. When installation completes, you will need to find the actuall location of your JDK and make Fedora accept your choice. You can do this by issuing:updatedb;locate javac |grep bin
This will list several options (at least two, the default one shipped with fedora, and the one you downloaded from Java Sun in step 2 above. In my case, I get:[root@DRACHE Download]# locate javac |grep bin/usr/bin/javac/usr/java/jdk1.6.0_10/bin/javac/usr/java/jdk1.6.0_11/bin/javac this is what we downloaded in step 2 above, we want to make make Fedora recognaze this jdk.
7. To make Fedora recognaze your jdk (JVM), use alternatives command and issue following 3 commands one after another:alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_11/bin/java 100
alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_11/bin/jar 100
alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_11/bin/javac 100
These 3 commands set your java, jar and javac commands. You can use same to set other java executables if you want.
8. Configure alternatives to use the jdk you downloaded above in step 2 rather than the java shipped with Fedora by issuing:/usr/sbin/alternatives --config java
This will present you with at least 2 options (one is the default jdk shipped with Fedora, other is jdk you downloaded in step 2 above). In my case, I have somehting like this but in your case, this can look different:/usr/sbin/alternatives --config java
There are 6 programs which provide java.
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 7/20
Selection Command----------------------------------------------- 1 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java 2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java* 3 /usr/java/default/bin/java + 4 /usr/java/jdk1.6.0_11/bin/java 5 /usr/java/jdk1.6.0_11/bin/jar 6 /usr/java/jdk1.6.0_11/bin/javac
Enter to keep the current selection[+], or type selection number:
9. Choose the one you downloaded in step 2 above and press . In my case, that is option 4.
10. repeat the same for jar and javac command as:/usr/sbin/alternatives --config jar
/usr/sbin/alternatives --config javac
11. Issue:java -version
and you will see something like this:
[dino@DRACHE Download]$ java -versionjava version 1.6.0_11Java(TM) SE Runtime Environment (build 1.6.0_11-b03)Java HotSpot(TM) Server VM (build 11.0-b16, mixed mode)
Now you are done. Hope this helps :)Mustafa Buljubasic
Thanks to article from Angsuman Chakraborty from August 7th, 2007
Useful links on how to install JDK, Adobe Flash Player, MP3 players, Media Players, Java Runtime, and much more :http://blog.taragana.com/index.php/archive/how-to-install-jdk-6-java-se-6-tomcat-in-fedora-core-6-fedora-7-in-5-minutes/http://www.mjmwired.net/resources/mjm-fedora-f10.html#java
Reply
20 zirimu andrew austin June 6, 2011 at 11:19 am
Thanks Mustafa, It worked like a charm for me , am using RHEL5
Reply
21 kieron August 23, 2011 at 4:41 am
Thanks, this helped me.
Fedora 14
Reply
22 Daniel Hannuschka November 12, 2011 at 12:13 am
Hey Mustafa,
it works very well but my command was another on ubuntu 11!I had to use :
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 8/20
daniels@daniels-X681X:/usr/bin$ sudo update-alternatives --config javaEs gibt nur eine Alternative in Link-Gruppe java: /usr/lib/jvm/java-6-openjdk/jre/bin/javaNichts zu konfigurieren.daniels@daniels-X681X:/usr/bin$ sudo update-alternatives --install /usr/bin/java java /home/jdk1.6.0_30/bin/java 100daniels@daniels-X681X:/usr/bin$ sudo update-alternatives --install /usr/bin/jar jar /home/jdk1.6.0_30/bin/jar 100daniels@daniels-X681X:/usr/bin$ sudo update-alternatives --install /usr/bin/javac javac /home/jdk1.6.0_30/bin/javac 100daniels@daniels-X681X:/usr/bin$ sudo update-alternatives --config javaEs gibt 2 Auswahlmglichkeiten fr die Alternative java (welche /usr/bin/java bereitstellen). Auswahl Pfad Prioritt Status------------------------------------------------------------* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 Auto-Modus 1 /home/jdk1.6.0_30/bin/java 100 manueller Modus 2 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manueller ModusDrcken Sie die Eingabetaste, um die aktuelle Wahl[*] beizubehalten,oder geben Sie die Auswahlnummer ein: 1update-alternatives: /home/jdk1.6.0_30/bin/java wird verwendet, um /usr/bin/java (java) im manueller Modus bereitzustellen.daniels@daniels-X681X:/usr/bin$ sudo update-alternatives --config jarEs gibt 3 Auswahlmglichkeiten fr die Alternative jar (welche /usr/bin/jar bereitstellen). Auswahl Pfad Prioritt Status------------------------------------------------------------* 0 /usr/lib/jvm/java-6-openjdk/bin/jar 1061 Auto-Modus 1 /home/jdk1.6.0_30/bin/jar 100 manueller Modus 2 /usr/bin/fastjar 100 manueller Modus 3 /usr/lib/jvm/java-6-openjdk/bin/jar 1061 manueller ModusDrcken Sie die Eingabetaste, um die aktuelle Wahl[*] beizubehalten,oder geben Sie die Auswahlnummer ein: 1update-alternatives: /home/jdk1.6.0_30/bin/jar wird verwendet, um /usr/bin/jar (jar) im manueller Modus bereitzustellen.daniels@daniels-X681X:/usr/bin$ sudo update-alternatives --config javacEs gibt 2 Auswahlmglichkeiten fr die Alternative javac (welche /usr/bin/javac bereitstellen). Auswahl Pfad Prioritt Status------------------------------------------------------------* 0 /usr/lib/jvm/java-6-openjdk/bin/javac 1061 Auto-Modus 1 /home/jdk1.6.0_30/bin/javac 100 manueller Modus 2 /usr/lib/jvm/java-6-openjdk/bin/javac 1061 manueller ModusDrcken Sie die Eingabetaste, um die aktuelle Wahl[*] beizubehalten,oder geben Sie die Auswahlnummer ein: 1update-alternatives: /home/jdk1.6.0_30/bin/javac wird verwendet, um /usr/bin/javac (javac) im manueller Modus bereitzustellen.daniels@daniels-X681X:/usr/bin$ java -versionjava version "1.6.0_30-ea"Java(TM) SE Runtime Environment (build 1.6.0_30-ea-b10)Java HotSpot(TM) Server VM (build 20.5-b02, mixed mode)daniels@daniels-X681X:/usr/bin$
Reply
23 S O February 28, 2012 at 4:33 pm
Thank you
Reply
24 archagy May 14, 2013 at 7:46 pm
Thanks very helpful
Reply
25 vishal joshi January 9, 2009 at 11:07 am
Dear Mustafa Buljubasic,thanking YOu so much.i need one more help.how to install tomcat and how to set environmental variable for that on linux.
Reply
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 9/20
26 Rudra January 20, 2009 at 10:31 am
You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:[# vi /etc/profile]
Next setup PATH / JAVA_PATH variables as follows:[export PATH=$PATH:/usr/java/jdk1.5.0_07/bin][export PATH=$PATH:/usr/java/jdk1.5.0_07/bin]
Reply
27 Pratap July 27, 2011 at 12:11 pm
Why do we need to SET path 2 times the same path??
Reply
28 notgzus July 28, 2011 at 6:07 pm
i think he ment:
export JAVA_HOME=$JAVA_HOME:/usr/java/jdk1.6.0_26/bin/javaexport PATH=$PATH:/usr/java/jdk1.6.0_26/bin
Reply
29 neha February 14, 2009 at 1:45 pm
hi can some one please help me out .. i just installed java 1.6 on REDHAT 5 system do i need 2 set da classpath or just path n javahome is sufficient .. i tried settng all da 3 bt i guess it didnt work .. can ne1 tel me wts dacorrect procedure to do it ..
Reply
30 Hermes Costell April 21, 2009 at 4:07 pm
Mustafa:
THANK YOU! These step-by-step instructions youve posted were exactly what I needed to install the JDK on RHEL 5.x
I am floored that there was no link or mention from Suns website on how to do this. Do they actually WANT people to use Java? If so it seems to me that if they provided instructions such as these along with the downloadsthat it would help their product get out a great deal.
Oh well.
Reply
31 Saurabh April 23, 2009 at 1:59 pm
Hi I am uing mandrivaI ran
export PATH=$PATH:/usr/lib/jvm/java-1.6.0-sun-1.6.0.06/jre/bin
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-sun-1.6.0.06/jre/bin/java
but got errors saying
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 10/20
: line 234: /usr/lib/jvm/java-1.6.0-sun-1.6.0.06/jre/bin/java/bin/java: Not a directory
Please Help me
Reply
32 Nagendra May 28, 2009 at 11:02 am
Dear Saurabh,
You have exported full path till bin in JAVA_HOME, Just set export JAVA_HOME=/usr/lib/jvm/java-1.6.0-sun-1.6.0.06/jre and it will work.
Reply
33 sasa June 18, 2009 at 2:05 pm
Thx to Mustafa.Your solution has been like Ado said ko kec na desetku
sve najbolje
Reply
34 Alok Guha June 24, 2009 at 10:12 am
Thanks..it worked.
Reply
35 Anuvrat Parashar October 1, 2009 at 4:03 am
I am using Mandriva Spring 09 and am trying to install IBM WebSphere and Eclipse on it. Eclipse runs fine but WebSphere says something goes wrong and does not start up. OpenJDK gets installed by default andJRE_HOME is set to the one for OpenJDK.I think that the trouble is because WebSphere does not support OpenJDK. I tried the above methods to export JRE_HOME=/usr/java/jre1.6.0_14/bin but it does not seem to work.especially when i ran source ~/.bash_profile it gave this error:
bash: TMOUT: readonly variable
help me out.
Reply
36 Prakash May 20, 2010 at 5:48 am
I installed jre-7 beat onto /opt .I appended the PATH of bin of java to /etc/environment variable and it works.
Reply
37 Arivillathamalayali May 20, 2010 at 6:52 am
java_vm throws out error java_vm process: could not find Java VM symbols ,Any Idea how to set PLUGIN_HOME variable for a jre 7 install(manually installed from jar archive)
Reply
38 ChromeFan May 23, 2010 at 12:21 am
Hi , set JAVA_HOME and PATH variables for every user under my Linux system(ubuntu 10.04)
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 11/20
open profile$sudo vi /etc/profile;insert into last line:#set java environmentJAVA_HOME=/usr/lib/jvm/java-6-sun // I am using jdk1.6.0.20CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarPATH=$PATH:$JAVA_HOME/binexport JAVA_HOMEexport CLASSPATHexport PATHexport GDK_NATIVE_WINDOWS=true #this is for setting eclipse#env GDK_NATIVE_WINDOWS=1 #me too!close and save it#shellsource /etc/profile //let profile workrebootTest if Java environment is successfully installed by typing in this in the shell:echo $JAVA_HOMEecho $PATH
Reply
39 Khan June 18, 2010 at 3:14 am
Hi ChromeFan, can u please help me in setting up theh enviromental variables in php.ini file as well.thanks
Reply
40 andy August 18, 2010 at 7:30 pm
I also like to learn how to change environment variables, like CLASSPATH and LD_LIBRARY_PATH in php.ini.thanks!
Reply
41 Dev September 6, 2010 at 10:13 am
hito everybdy, i have two versions of java installed on my system jdk1.5 and jdk 1.6. Now i want to make my jdk1.6 as the default version. I do not want to overwrite jdk 1.5. So plz send me the proceedure to solve thisissue.
Reply
42 Dev September 6, 2010 at 10:23 am
I want to implement all this on linux(fedora).
Reply
43 Yogesh September 16, 2010 at 4:51 am
Vivek, Im waiting for a tomcat howto :-)
Reply
44 Dev September 17, 2010 at 5:27 am
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 12/20
hi to evrybdydear yogesh dere is nothing much typical to wait for a tomcat..if u wan to set this on ur system then just set the path variable in /etc/bashrc file for all users..actually in my case problem is that i want toimplement this for my server.so plz send a correct information rather than any funny remarks.
Reply
45 Yogesh September 17, 2010 at 5:40 am
@Dave, with tomcat howto I mean a complete step by step guide to deploy tomcat app server and integrate it with existing apache with the help of mod_jk. And not just setting the path variable in /etc/bashrc asyou said. Setting path is something which I have learnt in my nursery rhymes.By the way the comment I posted was for site owner Vivek Gite and not you. Please read it again and dont comment until you are very sure about it!!
Reply
46 Dev September 20, 2010 at 5:12 am
oh great if uve learnt dis in ur nuresery rhymes den def u would be the right person who can help me to solve this..sory for misunderstnding. Actualy i m trying to set this path for long so ..
Reply
47 Dev September 20, 2010 at 5:13 am
oh great if uve learnt dis in ur nuresery rhymes den def u would be the right person who can help me to solve this..sory for misunderstnding. Actualy i m trying to set this path for long so.
Reply
48 soothsayer October 6, 2010 at 6:25 pm
I dont know what everyone else is saying. I just read the first couple of posts from people and found some people having issues with this.. However I just wanted to thank the person who wrote this article at the first place.The instructions worked perfect for me.. thanks a lot.
Reply
49 Shanaka November 5, 2010 at 5:02 am
Thanks This is very useful..
Reply
50 Karthigayan February 23, 2011 at 5:10 am
Thanks. This is excellent. This was very useful. Thank Musthafa
Reply
51 H.Martin March 17, 2011 at 6:24 pm
This does not work!
Reply
52 Mohammed April 20, 2011 at 7:04 am
Dear all,
Can anyone help me?
Ive installed jdk 1.6 update 24 and while opening appliciton its downloadin jdk 1.5,
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 13/20
from backend its showing 1.6 update 24, ive tried multiple noluck.
Regards,Fareed.
Reply
53 haasdas May 14, 2011 at 6:53 pm
I came across this:
sudo update-java-alternatives -s java-6-openjdk(ubuntu 10.10 for me)It seems to do a lot of stuff automatically!
Hope it helps some people out there
Reply
54 NARESH May 23, 2011 at 12:03 pm
/usr/lib64/gcc/x86_64-suse-linux/4.4/../../../../lib64/crt1.o: In function `_start:/usr/src/packages/BUILD/glibc-2.10.1/csu/../sysdeps/x86_64/elf/start.S:109: undefined reference to `maincollect2: ld returned 1 exit status
HOW TO SOLVE THIS PROBLEM PLEASE TELL ME MY OS IS LINUX OPEN SUSE AT THE TIME OF COMPILATION THIS ERROR APPEARED
Reply
55 mathi June 13, 2011 at 12:23 pm
Thanks a lot ..I also faced this problem for last three week. After seeing ur post, did what u explained here.Now working ya..
Reply
56 alsat June 13, 2011 at 5:27 pm
I installed sun-java from synaptic package manager and to initialize these variables i did as explained above..bt i thnk dr z sth wrong wid it.. i cannot start websphere because it returnd an error wid dese variables..Can any1 tel me wts d proper way of setting these variables and path and in what all files so that it is set for all users system wide?thnx!
Reply
57 RT July 27, 2011 at 2:48 pm
I keep getting a dependency problem when trying to install tomcat6 on rhel5:omcat6-6.0.29-1.jpp5.noarch from jpackage-generic-updates has depsolving problems> Missing Dependency: java is needed by package tomcat6-6.0.29-1.jpp5.noarch (jpackage-generic-updates)tomcat6-6.0.29-1.jpp5.noarch from jpackage-generic-updates has depsolving problems> Missing Dependency: java is needed by package tomcat6-6.0.29-1.jpp5.noarch (jpackage-generic-updates)Error: Missing Dependency: java is needed by package tomcat6-6.0.29-1.jpp5.noarch (jpackage-generic-updates)
But, java is installed correctly as far as I can see. java -version returnsjava version 1.6.0_26Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 14/20
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
Reply
58 RT July 27, 2011 at 2:52 pm
environment variables are setup correctly
env returns:
JAVA_HOME=usr/java/jdk1.6.0_26PATH=usr/java/jdk1.6.0_26/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/admin/bin
Reply
59 Sam November 7, 2011 at 3:37 am
Linux Mint 10.10 (should work the same in Ubuntu 10.10)By default you should be able to type:$ which javaand get:/usr/bin/java
/usr/bin/java is actually a symbolic link to /usr/lib/jvm/default-javaIf you try to set /usr/bin/java as JAVA_HOME, you will have problems.As a workaround, you should be able to set JAVA_HOME successfully using:export JAVA_HOME=/usr/lib/jvm/default-javaexport PATH=$PATH:$JAVA_HOME/bin
Reply
60 Pablo February 2, 2012 at 1:22 pm
Voc sauvou minha vida! Obrigado!
You sauve my life! Thank you!
Reply
61 spring March 21, 2012 at 5:10 pm
theres error in the article,export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/javashouldexport JAVA_HOME=/usr/java/jdk1.5.0_07/
Reply
62 ZehcnasAlex May 22, 2012 at 3:35 pm
Hi, maybe if youll try with apt-get install maven2, i did it in this way and still i dont have any problem.
Reply
63 yaseen May 31, 2012 at 8:23 am
Dear Guru,
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 15/20
I am new to sap.please send me document hot to install gateway instance using xmanager.please help me to this issue.my os is Linux susi 11 and database is oracel
RegardsYaseen
Reply
64 eb July 16, 2012 at 2:45 am
This article is stupidly wrong and user spring above is correct.First find out where your jdk is installed. Then set as below:export JAVA_HOME=/usr/java/jdk1.6.0_18
After doing this way my Tomcat install worked fine.
Reply
65 Gajesh September 14, 2012 at 12:35 pm
Hi I have installed cygwin for windows xp, can you please tell me how to set JAVA_HOME variable? its not taking the windows path.
Reply
66 seighalani December 16, 2012 at 8:59 pm
hi
thanks for your good article.please correct end of article. there is duplicate phrase . i mean
Next setup PATH / JAVA_PATH variables as follows:export PATH=$PATH:/usr/java/jdk1.5.0_07/binexport PATH=$PATH:/usr/java/jdk1.5.0_07/bin
Reply
67 Anugya February 26, 2013 at 12:49 pm
Thank It help me lot!!!!!!!!!!!!!!!!
Reply
68 sanjib deka April 16, 2013 at 9:30 am
I have installed jdk1.7.0.17. when i check java version and path it showsOpenJDK version and the path like/usr/lib/jvm/jre-1.7.0-17-openjdk.x86-64/bin/java.
How can change it to :
java version 1.7.0_17Java(TM) SE Runtime EnvironmentJava HotSpot(TM) Server VM
kindly help me please.
Reply
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 16/20
69 ash7 July 3, 2013 at 5:33 am
To summarise and simplify the procedure. The following would set the env variables for the particular user.Step 1. Open the ~/.bashrc filenano /home/user/.bashrc
Step 2: Set the environment variables as follows. Just put these on the top of the file and save it.# user defined environment variables# -export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-amd64export PATH=$PATH:/$JAVA_HOME/bin
Step 3. Logout and login again.
Step 4. Open terminal and type echo $JAVA_HOME and echo $PATHthis should return you the appropriate result as you had set.
Note: I have my java installed at /usr/lib/jvm/java-1.6.0-openjdk-amd64 location. It may vary in your system.
Reply
70 Atul September 10, 2013 at 5:34 pm
Thanks ash7 ! its Working..
Reply
71 Kiss September 11, 2013 at 10:49 am
I searched .bashrc in file system andi found 2 files bash.bashrc and 2 files dot.bashrc how can i choose the right one?in my home/user/ there is no file .bashrcplease help me!
Reply
72 sam ben March 27, 2014 at 7:29 pm
yeah it worked for me .. thanks man
Reply
73 Atul September 10, 2013 at 5:29 pm
System Got stuck!!!
Reply
74 saji November 6, 2013 at 11:14 am
i have problem for running selenium script in linux machine i have received this error
kindly help me out or pls give me messge ill cal clarify error mention below
com.sun.tools.javac.Main is not on the classpath.Perhaps JAVA_HOME does not point to the JDK.It is currently set to /usr/lib/jvm/java-7-openjdk-i386/jre
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 17/20
Reply
Leave a Comment
Name *
E-mail *
Notify me of followup comments via e-mail
Submit
Tagged as: export command, export path, java executable, java home variable, java jdk1, linux system, path variable, path variables, set environment variables, set PATH, startup script, vi command
Previous Faq: How to: Turning off SFTP server under Linux / UNIX cpanel server
Next Faq: Linux: Find out what kernel drivers (modules) are loaded
To search, type and hit enter
nixCraft
+ 13,575
Follow +1
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 18/20
Related Faqs
UNIX / Linux: Set your PATH Variable Using set or export Command
How to: Change Users bash profile under Linux / UNIX
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 19/20
Display or print UNIX / Linux path ~ $PATH variable
HowTo Run a Script In Linux
Linux: Change the PATH [ Add New Directory ]
Disable Caps Lock Key in Linux
Linux / Unix: Bash Shell See All Exported Variables and Functions
How To Read / Print $PATH Shell Variable
Bash Shell Script Function Examples
-
4/11/2014 How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ 20/20
Change default Linux / UNIX text editor from VI to Pico
Latest posts from our blog
Linux and Unix nload App: Monitor Network Traffic and Bandwidth Usage In Real Time10 Linux/Unix Bash and KSH Shell Job Control ExamplesDownload of The Day: FreeBSD 10 ISO DVD / CD Images30 Cool Open Source Software I Discovered in 2013Download Of The Day: Fedora Linux 20 (Heisenbug) CD / DVD ISO
Tweets by @nixcraft
Subscribe to nixCraft
Learn something new about Linux/Unix by email
Enter your email address:
Subscribe
2000-2014 nixCraft. All rights reserved. Privacy Policy - Terms of Service - Questions or Comments - We are proudly powered by Linux + Nginx + WordPress.The content is copyrighted to nixCraft and may not be reproduced on other websites.