Search code examples
javaubuntujava-home

How to set Oracle's Java as the default Java in Ubuntu?


How do I change the value of JAVA_HOME in Ubuntu to point to Oracle's Java?

Should it point to java-6-sun or java-6-sun-1.6.0.24 ?


Solution

  • I put the line:

    export JAVA_HOME=/usr/lib/jvm/java-7-oracle
    

    in my ~/.bashrc file.

    /usr/lib/jvm/java7-oracle should be a symbolic link pointing to /usr/lib/jvm/java-7-oracle-[version number here].

    The reason it's a symbolic link is that in case there's a new version of the JVM, you don't need to update your .bashrc file, it should automatically point to the new version.

    If you want to set JAVA_HOME environment variables globally and at system level means use should set in /etc/environment file.