View Full Version : [SOLVED] defined JAVA_HOME is not picked up some other path taken

August 1st, 2010, 10:36 AM
Ubuntu 9.04
I have in /etc/profile.d/jdk.sh

export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=$JAVA_HOME/bin:$PATH
but when I am typing
which java I see

root@tapas-laptop:/usr/lib/jvm/java-6-sun# which java
which is not set in PATH.
So why is this happening and how can I avoid this ?

August 1st, 2010, 01:56 PM
It is set in PATH or maybe I don't understand your question.

You add JAVA_HOME/bin to PATH and that is where java is, just like `which java` shows.

Just saw that this was related to another (http://ubuntuforums.org/showthread.php?t=1543461) thread you posted, which you tagged SOLVED.
Please do not double post like that. This is not a chat.

August 1st, 2010, 02:58 PM
This is not a chat.

This is a different problem.


but instead of that it is taking java from

both of the JAVA_HOME/bin are different directories

when I type
ant I got

Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-sun-
Buildfile: build.xml does not exist!
Build failed
The above java it picked is not the one I defined in JAVA_HOME.

August 1st, 2010, 03:03 PM
ok, sorry then ;)

if you browse to /usr/lib/jvm you will notice that java-6-sun is a symlink to folder java-6-sun-#

this is what it should be and and lets you have several java folders in /usr/lib/jvm

to list and switch installed java versions you use update-java-alternatives, see

man update-java-alternatives

August 1st, 2010, 03:24 PM
Oh yes you pointed the right thing.Thanks.

August 1st, 2010, 03:30 PM
sun-java6-jdk is in the partner repository

there are hundreds of post in this forum explaining how to enable it and install jdk (and I have written it before as well)

August 1st, 2010, 03:31 PM
I just installed
apt-get install sun-java6-jdk
but it was not in /usr/lib/jvm
Also I did a find / -name jdk
but there was no result where did it installed jdk.

root@tapas-laptop:/usr/lib# find / -name sun-java6-jdk*

August 1st, 2010, 03:43 PM
I don't think you understood my previous post about the symlink

package sun-java6-jdk installs to /usr/lib/jvm/java-6-sun-#/
(where # is the version number)

(is a symlink - like a shortcut in Windows - which points to the currently used java)

(is a command with which you set the java version to use)

August 1st, 2010, 04:02 PM
Hi I got my problem resolved.I checked /usr/lib/jvm/java-6-sun
and I found this time the number of directories had increased also the files were more then when I had not done

apt-get install sun-java6-jdk
So when I am typing ant the error which I reported is not coming.

I did not understood your reply completely for the sake of my understaning and if some one comes across this thread I will say please explain following

package sun-java6-jdk installs to /usr/lib/jvm/java-6-sun-#/
(where # is the version number)

(is a command with which you set the java version to use)

August 1st, 2010, 04:08 PM
Well, I think it's very clear. What exactly is unclear?
First I explain the differences between java-6-sun- (or whatever your version number is) and java-6-sun in the directory /usr/lib/jvm

Then I explain the command update-java-alternatives, with which you can switch between java versions (type man update-java-alternatives in a terminal to read more)

Glad your problems were resolved, also:

Mark the threads as solved when you get answers.

August 1st, 2010, 06:59 PM
package sun-java6-jdk installs to /usr/lib/jvm/java-6-sun-#/
(where # is the version number)

I am not clear with the above statement.As when it was jre there also it was in the same place.
Also when I installed jdk new files are there and old also existed.
I expected jdk to create a separate directory.
So I asked.

August 1st, 2010, 07:08 PM
JDK and JRE are installed into same top directory, JRE is installed in a sub-folder

File listing comparisons:
sun-java6-jre (http://packages.ubuntu.com/karmic/all/sun-java6-jre/filelist)
sun-java6-jdk (http://packages.ubuntu.com/karmic/i386/sun-java6-jdk/filelist)

Mark the threads as solved when you get answers

August 1st, 2010, 07:59 PM