Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have downloaded jdk1.6.0_32.bin (Sun JDK) from Oracle file, and I installed it in /usr/lib/jvm. Now when I try to compile a Java source file using javac it says:

 The program 'javac' can be found in the following packages:
 * openjdk-6-jdk
 * ecj
 * gcj-4.4-jdk
 * gcj-4.5-jdk
Try: sudo apt-get install <selected package>

It means that it is not getting the path of my installed java. Do I need to set a path? How can I make it to work?

share|improve this question

First, you should move the Sun JDK from /usr/lib/jvm to /usr/local/lib/jvm. Let the package manager manage all files in /usr, except under /usr/local, which is for files not managed by the package manager.

java and other executables need to be in your path. This happens automatically when you install a Java environment from Ubuntu, but Ubuntu does not ship the Oracle JRE (for legal reasons). So you need to one of two things:

  • Add the /usr/local/lib/jvm/bin directory to your path.
  • Create symbolic links from /usr/local/lib/jvm/bin to /usr/local/bin, by typing the following commands in a terminal:

    cd /usr/local/bin
    ln -s ../lib/jvm/bin/* .

I recommend the second method, that's what /usr/local/bin is for.

share|improve this answer

You can also refer to the following article: It has reference to the Java Update Script; works like a charm if you want to download and install the JDK manually. I have used this one personally and it does save on a lot of effort and potential problems.


You can add the PPA referenced in this article:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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