Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

2 Answers 2

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: http://www.webupd8.org/2010/04/java-update-script-for-ubuntu-version.html 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.

OR,

You can add the PPA referenced in this article: http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html

share|improve this answer

Your Answer

 
discard

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.