I'm running Pangolin (12.04 LTS) and want to sort out some Java stuff where my JVM is pointing at a different place to my Compiler.

To demonstrate, my JVM is as follows:

pcrow@pcrow-HP-notebook:~/Documents$ java -version
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.4)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

Whereas my Compiler points here:

pcrow@pcrow-HP-notebook:~/Documents$ javac -version
javac 1.7.0_51

I have configured the latter through adding an entry to my ~/.profile file. The thing is that I'm not sure what sets the former and I want them to be consistent. In '/etc/environment' I have the following entry:


And when I run printenv | grep "java"


Can you tell me where IcedTea6 is most likely set up on Ubuntu? I'd like to override it if I can and make sure my JVM and Compiler are both using the same version.

  • 1
    What is the output of which java and which javac?
    – Aaron
    Feb 13, 2014 at 19:17
  • each command points to /usr/bin/java and /usr/bin/javac respectively and I subsequently see that those locations are specified in the PATH variable as it is specified in /etc/environment
    – Crowie
    Feb 14, 2014 at 1:30

2 Answers 2


Starting with your last paragraph

Can you tell me where IcedTea6 is most likely set up on Ubuntu? I'd like to override it if I can and make sure my JVM and Compiler are both using the same version.

Ubuntu provides a nice tool to select one JDK/JRE from multiple installations. This is update-java-alternatives. It is closely tied to the update-alternatives tool.

Each JDK/JRE includes a set of java tools like javac, java, javaws, jinfo, javah etc. An installation may come with a hidden .jinfo file where these java components are listed. In my system, when I install the openjdk-8-jdk package, a file /usr/lib/jvm/.java-1.8.0-openjdk-amd64.jinfo is created. The content of that file is (skipped some lines)


hl rmid /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/rmid
hl java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
hl keytool /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/keytool
hl jjs /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/jjs
hl pack200 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/pack200
hl rmiregistry /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/rmiregistry
. (skipped lines)
jdkhl jdb /usr/lib/jvm/java-8-openjdk-amd64/bin/jdb
jdkhl serialver /usr/lib/jvm/java-8-openjdk-amd64/bin/serialver
jdkhl wsgen /usr/lib/jvm/java-8-openjdk-amd64/bin/wsgen
jdkhl jcmd /usr/lib/jvm/java-8-openjdk-amd64/bin/jcmd
jdk appletviewer /usr/lib/jvm/java-8-openjdk-amd64/bin/appletviewer
jdk jconsole /usr/lib/jvm/java-8-openjdk-amd64/bin/jconsole
plugin mozilla-javaplugin.so /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/IcedTeaPlugin.so

update-java-alternatives uses this file to create alternatives links in /etc/alternatives directory. The purpose of this directory is to provide a mechanism by which you can select a default program from a set of similar tools. This is great for multiple versions of JDK (see more in update-alternatives)

Brief discussion of update-alternatives

To demonstrate the process briefly. When a program is first installed it registers its alternatives for a master name (like javac) in alternatives database (This is contained in /var/lib/dpkg/alternatives directory). During the installation process, update-alternatives creates a master link in /usr/bin/javac pointing to /etc/alternatives/javac, which is also a symlink pointing to the actual file from the JDK.

Now, When you install another JDK, this too will have a javac program. So, while installing the second JDK update-alternatives automatically updates the /etc/alternatives/javac symlink to point to the one with highest priority . It also updates the alternatives database, so that you can manually select a default by calling it.

Back to the update-java-alternatives

update-java-alternatives uses update-alternatives to provide a whole set defaults from a single JDK/JRE installation. The idea is you will select a JDK/JRE installation and all tools from that JRE/JDK will be used as default for providing multiple java tools, saving you from using update-alternatives for each tool. So, when you use update-java-alternatives to select a JDK, say openjdk-8-jdk for example, it makes the java tools of this JDK (such as javac, java, javaws etc) as default. Provided that the JDK is installed correctly and it lists its tools in .jinfo file.


So, to answer your query in short, IcedTea6 Plugin is configured in the .jinfo file and update-java-alternatives uses that file to update the links to point to it. So, you need to create a file for your JDK listing the plugin and all java tools and use update-java-alternatives.

If you installed JDK/JRE manually, check this question to get help making it recognized by the update-java-alternatives tool.

But we still have problems...

It seems this update-java-alternatives is not updating JDK components anymore lately. It's only updating JRE's tools. There are lots of complaints saying using this tool doesn't update all java components. After experiencing the same problem and spending almost 5 hours on it, I think I've found a fix. The solution is just changing hl to jre and jdkhl to jdk in .jinfo file. I've found an old .jinfo file on github where those were jre and jdk.

The fix for .jinfo file.

So, To fix it use you need to change hl and jdkhls. If your file is .openjdk-8-jdk.jinfo in /usr/lib/jvm/ use this command

sudo sed -i 's/^hl/jre/p' /usr/lib/jvm/.openjdk-8-jdk.jinfo
sudo sed -i 's/^jdkhl/jdk/p' /usr/lib/jvm/.openjdk-8-jdk.jinfo

Now to update, first list the alternatives

sudo update-java-alternatives -l

It will return something like this (the actual reply may be different for you)

java-1.8.0-openjdk-amd64       1081       /usr/lib/jvm/java-1.8.0-openjdk-amd64
jdk1.8.0_65                    1081       /usr/lib/jvm/jdk1.8.0_65

Copy the alternative name from the first column and use it to set default. To set jdk1.8.0_65 as default I'd use

sudo update-java-alternatives -s jdk1.8.0_65 -v

Now, check the java and javac version.


My PATH is in some way influenced by the file /etc/environment as you can see:


When I execute which java and which javac I see something like follows:


Now, I can't be sure the two are related.* but as a Java dev I'm often adding things to Path - it's how we influence CLASSPATH so that our Java classes are available. And in the Path configuration above you see this excerpt:


I don't know what that means. Nevertheless by following the targets given to me by the which command I come to a set of links to executables. Looking at the targets of those links I get something like:


Unsure on next steps. Copy those links, back them up or remove them. A bit of trial and error and Googling are the next steps. I haven't googled the difference between javac -version and which but I should

HTH and thanks to BryceAtNetwork23

  • 1
    I wasn't gonna suggest that, but tbh it doesn't make any sense to me! (that's probably just me though) Anyway, it's an "unanswered" question at the moment, so it's nice for the site if you tidy it up somehow :)
    – Zanna
    Oct 11, 2016 at 4:50
  • 1
    You mean my comment wasn't the best implementation of a suggestion? Happy to chat if you want! I don't want to flag for a mod since you can easily fix it yourself :)
    – Zanna
    Oct 11, 2016 at 5:08
  • 1
    Crowie, Most of this answer seems to me like an update to your question. I didn't explain your question, that is how javac is being set. Do you have updates to add to this answer?
    – Anwar
    Oct 28, 2016 at 6:05
  • 2
    I believe I also had it as the accepted answer at one point but unselected my answer as I didn't think it was sufficient personally.
    – Crowie
    Oct 28, 2016 at 6:59
  • 2
    @Crowie I've added another answer. Hope you will find that one helpful
    – Anwar
    Nov 2, 2016 at 10:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .