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

Ashish Agarwal picture Ashish Agarwal · Jun 25, 2011 · Viewed 301k times · Source

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 ?

Answer

srkiNZ84 picture srkiNZ84 · Jun 25, 2011

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.