I installed openjdk-7-jdk using apt-get install. However, when I type 'javac', the terminal says, 'bash: /usr/bin/javac: No such file or directory'. I think the link is broken, but how can I fix it?

Note: I installed openjdk-7-jdk before, but then I removed openjdk and installed sun-java. Now I deleted sun-jdk and want to go back to openjdk, but javac is not recognized. I'm using Ubuntu 11.10.

Edit: Recognized: java; Not Recognized: javac, javadoc, appletviewer, ...

1 Answer 1


The following workaround worked for me:

sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-7-openjdk-amd64/bin/javac 1

Installing java on Ubuntu was much easier some years ago. I don't know why the hell the guys at Canonical make it more and more complex.

  • It is still easy, but if you follow some outdated blog on the internet and break it manually, it's your own fault...
    – Lekensteyn
    Feb 2, 2012 at 15:11
  • Sorry, but I did not follow any outdated blog. I just installed the JDK with apt-get install java7-jdk. Feb 4, 2012 at 14:36
  • Did you mean openjdk-7-jdk?
    – Lekensteyn
    Feb 4, 2012 at 15:01
  • aptitude show java7-jdk tells State: not a real package and Provided by: openjdk-7-jdk. So, the answer is yes and no. Feb 6, 2012 at 10:35
  • that looks like it works; I already reinstalled Ubuntu though Jun 26, 2012 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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