Sie sind auf Seite 1von 20

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

AIX AIX

Blog About Contact us Forum Linux Scripting Guide RSS/FEED Linux FAQ / Howtos How to Set

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

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

newly created files. Set JAVA_HOME / PATH for a single user

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

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:

exportJAVA_HOME=/usr/java/jdk1.5.0_07/bin/java

Set PATH as follows:

exportPATH=$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:

$whichjava

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:

exportPATH=$PATH:/usr/java/jdk1.5.0_07/bin

exportPATH=$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

{ 74 comments… read them below or add one }

1 dino November 13, 2007 at 5:23 am

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

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

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

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

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

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

6

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

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

Hi Mustafa,

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

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.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

8 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

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

10 csr June 3, 2011 at 7:15 am

+1 Made my day. Thank you.

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

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

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

My appologies.

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

14 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.

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.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

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?

17 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

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

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

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

chmod755jdk-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/javajava/usr/java/jdk1.6.0_11/bin/java100

alternatives--install/usr/bin/jarjar/usr/java/jdk1.6.0_11/bin/jar100

alternatives--install/usr/bin/javacjavac/usr/java/jdk1.6.0_11/bin/javac100

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--configjava

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--configjava

There are 6 programs which provide ‘java’.

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

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--configjar

/usr/sbin/alternatives--configjavac

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 :

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

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

21 kieron August 23, 2011 at 4:41 am

Thanks, this helped me.

Fedora 14

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

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

daniels@daniels-X681X:/usr/bin$sudoupdate-alternatives --configjava

EsgibtnureineAlternativeinLink-Gruppejava:/usr/lib/jvm/java-6-openjdk/jre/bin/java

Nichtszukonfigurieren.

daniels@daniels-X681X:/usr/bin$sudoupdate-alternatives--install/usr/bin/javajava/home/jdk1.6.0_30/bin/java100

daniels@daniels-X681X:/usr/bin$sudoupdate-alternatives--install/usr/bin/jarjar/home/jdk1.6.0_30/bin/jar100

daniels@daniels-X681X:/usr/bin$sudoupdate-alternatives--install/usr/bin/javacjavac/home/jdk1.6.0_30/bin/javac100

daniels@daniels-X681X:/usr/bin$sudoupdate-alternatives --configjavaEsgibt2AuswahlmöglichkeitenfürdieAlternativejava(welche/usr/bin/javabereitstellen).

Auswahl

Pfad

PrioritätStatus

------------------------------------------------------------

*0

/usr/lib/jvm/java-6-openjdk/jre/bin/java 1061

Auto-Modus

1

/home/jdk1.6.0_30/bin/java

100

manuellerModus

2

/usr/lib/jvm/java-6-openjdk/jre/bin/java 1061

manuellerModus

DrückenSiedieEingabetaste,umdieaktuelleWahl[*]beizubehalten,

odergebenSiedieAuswahlnummerein:1

update-alternatives:/home/jdk1.6.0_30/bin/javawirdverwendet,um/usr/bin/java(java)immanuellerModusbereitzustellen.

daniels@daniels-X681X:/usr/bin$sudoupdate-alternatives --configjar

Esgibt3AuswahlmöglichkeitenfürdieAlternativejar(welche/usr/bin/jarbereitstellen).

Auswahl

Pfad

PrioritätStatus

------------------------------------------------------------

*0

/usr/lib/jvm/java-6-openjdk/bin/jar 1061

Auto-Modus

1

/home/jdk1.6.0_30/bin/jar

100

manuellerModus

2

/usr/bin/fastjar

100

manuellerModus

3

/usr/lib/jvm/java-6-openjdk/bin/jar 1061

manuellerModus

DrückenSiedieEingabetaste,umdieaktuelleWahl[*]beizubehalten,

odergebenSiedieAuswahlnummerein:1

update-alternatives:/home/jdk1.6.0_30/bin/jarwirdverwendet,um/usr/bin/jar(jar)immanuellerModusbereitzustellen.

daniels@daniels-X681X:/usr/bin$sudoupdate-alternatives --configjavac

Esgibt2AuswahlmöglichkeitenfürdieAlternativejavac(welche/usr/bin/javacbereitstellen).

Auswahl

Pfad

PrioritätStatus

------------------------------------------------------------

*0

/usr/lib/jvm/java-6-openjdk/bin/javac 1061

Auto-Modus

1

/home/jdk1.6.0_30/bin/javac

100

manuellerModus

2

/usr/lib/jvm/java-6-openjdk/bin/javac 1061

manuellerModus

DrückenSiedieEingabetaste,umdieaktuelleWahl[*]beizubehalten,

odergebenSiedieAuswahlnummerein:1

update-alternatives:/home/jdk1.6.0_30/bin/javacwirdverwendet,um/usr/bin/javac(javac)immanuellerModusbereitzustellen.

daniels@daniels-X681X:/usr/bin$java-version

javaversion"1.6.0_30-ea"

Java(TM)SERuntimeEnvironment(build1.6.0_30-ea-b10)

JavaHotSpot(TM)ServerVM(build20.5-b02,mixedmode)

daniels@daniels-X681X:/usr/bin$

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

Thank you

24 archagy May 14, 2013 at 7:46 pm

Thanks very helpful

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.

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

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]

27 Pratap July 27, 2011 at 12:11 pm

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

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/java export PATH=$PATH:/usr/java/jdk1.6.0_26/bin

29 neha February 14, 2009 at 1:45 pm

hi can some one please help me out correct procedure to do it

i just installed java 1.6 on REDHAT 5 system do i need 2 set da classpath or just path n javahome is sufficient

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

Mustafa:

i tried settng all da 3 bt i guess it didnt work

THANK YOU! These step-by-step instructions you’ve posted were exactly what I needed to install the JDK on RHEL 5.x

can ne1 tel me wts da

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.

31 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

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

: 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

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.

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

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

Thanks

it worked.

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 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.

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.

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)

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

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

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

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

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!

41 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.

42 Dev September 6, 2010 at 10:23 am

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

43 Yogesh September 16, 2010 at 4:51 am

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

44 Dev September 17, 2010 at 5:27 am

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

hi to evrybdy…dear yogesh dere is nothing much typical to wait for a tomcat

implement this for my server.so plz send a correct information rather than any funny remarks.

if

u wan to set this on ur system then just set the path variable in /etc/bashrc file for all users

45 Yogesh September 17, 2010 at 5:40 am

actually

in my case problem is that i want to

@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!!

46 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

47

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.

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

The instructions worked perfect for me

thanks a lot.

49 Shanaka November 5, 2010 at 5:02 am

Thanks This is very useful

50 Karthigayan February 23, 2011 at 5:10 am

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

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

This does not work!

52 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,

However I just wanted to thank the person who wrote this article at the first place.

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

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

Regards,

Fareed.

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

54 NARESH May 23, 2011 at 12:03 pm

/

/usr/src/packages/BUILD/glibc-2.10.1/csu/

collect2: ld returned 1 exit status

/usr/lib64/gcc/x86_64-suse-linux/4.4/

/

/

/lib64/crt1.o: In function `_start’:

/sysdeps/x86_64/elf/start.S:109:

undefined reference to `main’

HOW TO SOLVE THIS PROBLEM PLEASE TELL ME MY OS IS LINUX OPEN SUSE AT THE TIME OF COMPILATION THIS ERROR APPEARED

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……

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

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!

i cannot start websphere because it returnd an error wid dese variables

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 returns java version “1.6.0_26″ Java(TM) SE Runtime Environment (build 1.6.0_26-b03)

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

58 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

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

60 Pablo February 2, 2012 at 1:22 pm

Você sauvou minha vida! Obrigado!

You sauve my life! Thank you!

61 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/

62 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.

63 yaseen May 31, 2012 at 8:23 am

Dear Guru,

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

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

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.

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.

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

67 Anugya February 26, 2013 at 12:49 pm

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

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 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.

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

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 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.

70 Atul September 10, 2013 at 5:34 pm

Thanks ash7 ! it’s Working

71 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!

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

yeah it worked for me

thanks man

73

Atul September 10, 2013 at 5:29 pm

System Got stuck!!!

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

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

Reply Leave a Comment

Name *

E-mail *

LinuxBash Profile Reply Leave a Comment Name * E-mail * Notify me of followup comments via

Notify me of followup comments via e-mailLinuxBash Profile Reply Leave a Comment Name * E-mail * Submit Tagged as: export command ,

Submit
Submit
To search, type and hit en nixCraft Follow +1 + 13,575
To search, type and hit en
nixCraft
Follow
+1
+ 13,575

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

Related Faqs
Related Faqs

4/11/2014

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile

Howto Set JAVA_HOME / PATH variables Under LinuxBash Profile Change default Linux / UNIX text editor

Change default Linux / UNIX text editor from VI to Pico

Latest posts from our blog   Linux and Unix nload App: Monitor Network Traffic and
Latest posts from our blog  
Latest posts from our blog  

Latest posts from our blog

 
Linux and Unix nload App: Monitor Network Traffic and Bandwidth Usage In Real Time

Linux and Unix nload App: Monitor Network Traffic and Bandwidth Usage In Real Time

10 Linux/Unix Bash and KSH Shell Job Control Examples  

10

Linux/Unix Bash and KSH Shell Job Control Examples

 
Download of The Day: FreeBSD 10 ISO DVD / CD Images

Download of The Day: FreeBSD 10 ISO DVD / CD Images

30 Cool Open Source Software I Discovered in 2013

30

Cool Open Source Software I Discovered in 2013

Tweets Download by @nixcraft Of The Day: Fedora Linux 20 (Heisenbug) CD / DVD ISO

Tweets Download by @nixcraft Of The Day: Fedora Linux 20 (Heisenbug) CD / DVD ISO

Tweets Download by @nixcraft Of The Day: Fedora Linux 20 (Heisenbug) CD / DVD ISO
Subscribe to nixCraft  

Subscribe to nixCraft

 

Learn something new about Linux/Unix by email Enter your email address:

Subscribe
Subscribe

©2000-2014 The content is nixCraft. copyrighted All rights to nixCraft reserved. and may Privacy not Policy be reproduced - Terms of on Service other websites. - Questions or Comments - We are proudly powered by Linux + Nginx + WordPress.