3

Ubuntu 14.04 comes with OpenJDK after updating from 13.10.

$ java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
$

What is the safest way to switch to Oracle Java JDK? I have some Java developments tools (Eclipse, IntelliJ, Android Studio) and I would not like to break them after switching to Oracle JDK.

The reason for this is because these tool are warning me that I should switch to Oracle JDK to gain performance and to prevent some issue existing in OpenJDK.

8

Install Oracle/Sun Java. See How can I install Sun/Oracle's proprietary Java JDK 6/7/8 or JRE? (and others) for details.

In a terminal session, run : sudo update-alternatives --config java

You will get a list that looks something like this:

enter image description here

As per the instructions at the prompt, enter the number corresponding to the version you want to be your system default Java implementation.

Once you've done that, unless there are configuration settings directing otherwise for particular applications (quite common), the Java version you've chosen will be your global system default.

I would definitely not recommend removing entirely the OpenJDK. There are any number of modules and applications that may be expecting OpenJDK to be there and are configured to use it - it's the default Java that comes with Ubuntu. Removing it may cause some serious problems. Leave it in place for those modules that expect it, because it is the default. You have set the default to what you want, and you can control the applications you are using to use that setting (in fact you can do it on an application by application basis without changing the system default at all) - but not everything is under your control, at least not without some serious expertise and mucking around.

3

This is what I generally do:

First, remove the openjdk:

sudo apt-get remove openjdk

Then, download the latest java installer/tarball (I prefer tarball) from Oracle site.

Extract the tarball in your preferred location, or alternatively run the installer.

Edit your ~/.profile file and add the java executable path and java home variables:

export JAVA_HOME=/path/to/jdk1.8.0_05/bin/java
export PATH=$JAVA_HOME/bin:$PATH

Now you may run your eclipse or other programs that you have downloaded using this JDK installation.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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