How to Set JAVA_HOME / PATH variables Under Linux Bash Profile

by on October 10, 2007 · 76 comments· LAST UPDATED May 25, 2012

in , ,

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 variables such 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

Login to your account and open .bash_profile file
$ vi ~/.bash_profile
Set JAVA_HOME as follows using syntax export JAVA_HOME=<path-to-java>. 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!

{ 76 comments… read them below or add one }

1 dino November 13, 2007 at 5:23 am

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.sh
echo ‘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 answer
Thanks in Advnace

Reply

5 Chandrasekar February 16, 2011 at 6:57 am

use “sudo ” if you’re using ubuntu.
else try using “su”
Try googling in case both don’t work :D

Reply

6 Sreenivasa Reddy Mulinti March 23, 2014 at 5:03 am

Hi Mustafa,

Thank you for solution. This worked perfectly for me in Linux.

Reply

7 batman May 28, 2014 at 10:57 pm

Thank you. This worked. Nothing else did!

Reply

8 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.sh
echo ‘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
java version “1.6.0_03″
Java(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

9 sandeep February 2, 2011 at 8:59 am

hay it is working…but how can i set permentally set…the java path
its working only one terminoal only…
i need permentally java path setting
help me

Reply

10 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

11 Francisco November 18, 2014 at 3:55 am

review of these lines:
……
1. To set the environment variables:

echo ‘export JAVA_HOME=/opt/jdk1.5.0_12′ > /etc/profile.d/jdk.sh
echo ‘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

…..

I have the same problem, something at the startup doesn´t work well in /etc/profile from the /etc/profile.d/*.sh are called.

To resolve this, put the exports directly at the end of the /etc/profile file..
and you have permanently set them, JAVA_HOME and JRE_HOME

regards

Reply

12 csr June 3, 2011 at 7:15 am

+1 Made my day. Thank you.

Reply

13 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

Reply

14 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.sh
istead of
echo ‘export JAVA_HOME=/opt/jdk1.5.0_12′ > /etc/profile.d/jdk.sh

My appologies.

Reply

15 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

16 Ado January 29, 2008 at 9:21 am

Mustafa-pasa,

bas se nesto gnjavim sa serverom ali ovaj tvoj post je dosao k’o kec na desetku.

Thanks for your post, it does exactly what it says on the tin. Just what I needed.

Reply

17 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.jar
it 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

18 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

19 rupert June 13, 2008 at 10:39 pm

I think it’s 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 java
or
sudo update-alternatives –config java

Reply

20 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

21 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.jsp
As 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’.

  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 -version
java version “1.6.0_11″
Java(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

22 zirimu andrew austin June 6, 2011 at 11:19 am

Thanks Mustafa, It worked like a charm for me , am using RHEL5

Reply

23 kieron August 23, 2011 at 4:41 am

Thanks, this helped me.

Fedora 14

Reply

24 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 :

daniels@daniels-X681X:/usr/bin$ sudo update-alternatives  --config java
Es gibt nur eine Alternative in Link-Gruppe java: /usr/lib/jvm/java-6-openjdk/jre/bin/java
Nichts zu konfigurieren.
daniels@daniels-X681X:/usr/bin$ sudo update-alternatives --install /usr/bin/java java /home/jdk1.6.0_30/bin/java 100
daniels@daniels-X681X:/usr/bin$ sudo update-alternatives --install /usr/bin/jar jar /home/jdk1.6.0_30/bin/jar 100
daniels@daniels-X681X:/usr/bin$ sudo update-alternatives --install /usr/bin/javac javac /home/jdk1.6.0_30/bin/javac 100
daniels@daniels-X681X:/usr/bin$ sudo update-alternatives  --config javaEs gibt 2 Auswahlmöglichkeiten für die Alternative java (welche /usr/bin/java bereitstellen).
  Auswahl      Pfad                                      Priorität 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 Modus
Drücken Sie die Eingabetaste, um die aktuelle Wahl[*] beizubehalten,
oder geben Sie die Auswahlnummer ein: 1
update-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 jar
Es gibt 3 Auswahlmöglichkeiten für die Alternative jar (welche /usr/bin/jar bereitstellen).
  Auswahl      Pfad                                 Priorität 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 Modus
Drücken Sie die Eingabetaste, um die aktuelle Wahl[*] beizubehalten,
oder geben Sie die Auswahlnummer ein: 1
update-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 javac
Es gibt 2 Auswahlmöglichkeiten für die Alternative javac (welche /usr/bin/javac bereitstellen).
  Auswahl      Pfad                                   Priorität 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 Modus
Drücken Sie die Eingabetaste, um die aktuelle Wahl[*] beizubehalten,
oder geben Sie die Auswahlnummer ein: 1
update-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 -version
java 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

25 S O February 28, 2012 at 4:33 pm

Thank you

Reply

26 archagy May 14, 2013 at 7:46 pm

Thanks very helpful

Reply

27 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

28 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

29 Pratap July 27, 2011 at 12:11 pm

Why do we need to SET path 2 times the same path??

Reply

30 notgzus July 28, 2011 at 6:07 pm

i think he ment:

export JAVA_HOME=$JAVA_HOME:/usr/java/jdk1.6.0_26/bin/java
export PATH=$PATH:/usr/java/jdk1.6.0_26/bin

Reply

31 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 da correct procedure to do it ..

Reply

32 Hermes Costell April 21, 2009 at 4:07 pm

Mustafa:

THANK YOU! These step-by-step instructions you’ve 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 Sun’s 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 downloads that it would help their product get out a great deal.

Oh well.

Reply

33 Saurabh April 23, 2009 at 1:59 pm

Hi I am uing mandriva
I 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

: 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

34 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

35 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

36 Alok Guha June 24, 2009 at 10:12 am

Thanks..
it worked.

Reply

37 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 and JRE_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

38 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

39 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

40 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)
open profile
$sudo vi /etc/profile;
insert into last line:
#set java environment
JAVA_HOME=/usr/lib/jvm/java-6-sun // I am using jdk1.6.0.20
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME
export CLASSPATH
export PATH
export GDK_NATIVE_WINDOWS=true #this is for setting eclipse
#env GDK_NATIVE_WINDOWS=1 #me too!
close and save it
#shell
source /etc/profile //let profile work
reboot
Test if Java environment is successfully installed by typing in this in the shell:
echo $JAVA_HOME
echo $PATH

Reply

41 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

42 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

43 Dev September 6, 2010 at 10:13 am

hi…to 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 this issue.

Reply

44 Dev September 6, 2010 at 10:23 am

I want to implement all this on linux(fedora).

Reply

45 Yogesh September 16, 2010 at 4:51 am

Vivek, I’m waiting for a tomcat howto :-)

Reply

46 Dev September 17, 2010 at 5:27 am

hi to evrybdy…dear 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 to implement this for my server.so plz send a correct information rather than any funny remarks.

Reply

47 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’ as you 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 don’t comment until you are very sure about it!!

Reply

48 Dev September 20, 2010 at 5:12 am

oh great if u’ve 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

49 Dev September 20, 2010 at 5:13 am

oh great if u’ve 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

50 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

51 Shanaka November 5, 2010 at 5:02 am

Thanks This is very useful..

Reply

52 Karthigayan February 23, 2011 at 5:10 am

Thanks. This is excellent. This was very useful. Thank Musthafa

Reply

53 H.Martin March 17, 2011 at 6:24 pm

This does not work!

Reply

54 Mohammed April 20, 2011 at 7:04 am

Dear all,

Can anyone help me?

I’ve installed jdk 1.6 update 24 and while opening appliciton its downloadin jdk 1.5,

from backend its showing 1.6 update 24, i’ve tried multiple noluck.

Regards,
Fareed.

Reply

55 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

56 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 `main’
collect2: 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

57 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

58 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

59 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 returns
java version “1.6.0_26″
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

Reply

60 RT July 27, 2011 at 2:52 pm

environment variables are setup correctly

env returns:

JAVA_HOME=usr/java/jdk1.6.0_26
PATH=usr/java/jdk1.6.0_26/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/admin/bin

Reply

61 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 java
and get:
/usr/bin/java

/usr/bin/java is actually a symbolic link to /usr/lib/jvm/default-java
If 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-java
export PATH=$PATH:$JAVA_HOME/bin

Reply

62 Pablo February 2, 2012 at 1:22 pm

Você sauvou minha vida! Obrigado!

You sauve my life! Thank you!

Reply

63 spring March 21, 2012 at 5:10 pm

there’s error in the article,
export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java
should
export JAVA_HOME=/usr/java/jdk1.5.0_07/

Reply

64 ZehcnasAlex May 22, 2012 at 3:35 pm

Hi, maybe if you’ll try with apt-get install maven2, i did it in this way and still i dont have any problem.

Reply

65 yaseen May 31, 2012 at 8:23 am

Dear Guru,
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

Regards
Yaseen

Reply

66 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

67 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

68 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/bin
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin

Reply

69 Anugya February 26, 2013 at 12:49 pm

Thank It help me lot!!!!!!!!!!!!!!!!

Reply

70 sanjib deka April 16, 2013 at 9:30 am

I have installed jdk1.7.0.17. when i check java version and path it shows
OpenJDK 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_17″
Java(TM) SE Runtime Environment
Java HotSpot(TM) Server VM

kindly help me please.

Reply

71 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 file
nano /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-amd64
export PATH=$PATH:/$JAVA_HOME/bin

Step 3. Logout and login again.

Step 4. Open terminal and type echo $JAVA_HOME and echo $PATH
this 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

72 Atul September 10, 2013 at 5:34 pm

Thanks ash7 ! it’s Working..

Reply

73 Kiss September 11, 2013 at 10:49 am

I searched “.bashrc” in file system and
i 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 .bashrc
please help me!

Reply

74 sam ben March 27, 2014 at 7:29 pm

yeah it worked for me .. thanks man

Reply

75 Atul September 10, 2013 at 5:29 pm

System Got stuck!!!

Reply

76 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”

Reply

Leave a Comment

Tagged as: , , , , , , , , , , ,

Previous Faq:

Next Faq: