I have install java through yum on CentOS, however another java programme needs to know what the JAVA_HOME environmental variable is. I know all about setting environmental variables, but what do I set it to? java is installed in /usr/bin/java, it can't be there!

link|improve this question

79% accept rate
feedback

4 Answers

up vote 3 down vote accepted

Actually I found it,

it's /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/. I found out what it was by doing update-alternatives --display java and it showed me the directory /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

link|improve this answer
feedback

I'm not quite sure but if you install the normal RPMS the JAVA_HOME value can also be set to this:

/usr/java/default/

EDIT: I just checked on my home system. I have created this file:

/etc/profile.d/java.sh

That contains:

export JAVA_HOME=/usr/java/default/

and I'm using the official version from Sun: jdk-1.6.0_12-fcs

[EDIT] I documented my settings here.

link|improve this answer
oh interesting. :) – Rory Aug 6 '09 at 13:19
feedback

Thats weird, the whole point of having a JAVE_HOME environmental variable is so you don't have to specify the path to each program, it can get this path by looking for this variable.

Either way, the correct way to find the environmental variable for JAVA_HOME is to use echo:

[root@host ~]# echo $JAVA_HOME
/usr/java/j2sdk1.4.2_09

Running this command will display the path no matter what version you are running, from command line.

link|improve this answer
The variable had not been set. – Rory Aug 6 '09 at 13:19
feedback

You want to set JAVA_HOME to be the root location of the JDK or JRE, for example:

export JAVA_HOME=/usr/java/jdk1.3

If the JDK (Development kit) is installed, ypu probably want it to point to that, else use the JRE path (Java Runtime Environment). Then, you might want to set your $PATH environment variable to include the bin directory as well:

export PATH=$PATH:/usr/java/jdk1.3/bin

If you are using tomcat, you might also need to set CATALINA_HOME for the tomcat user.

export CATALINA_HOME=/path/to/tomcat

To set this for the system you want to edit your /etc/profile or add a .sh file in /etc/profile.d folder. For a particular user you can put it in the users ~/.profile or ~/.bash_profile files.

link|improve this answer
I wonder if there is a good reason the install doesn't do this for you if run as the super user, I always find it irritating ... – Kyle Brandt Aug 6 '09 at 13:15
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.