How to install oracle’s Java in Debian Stretch
If you are running Debian Stretch you probably have already Java installed, more concretely the OpenJDK version. But at times we need, or simply prefer, to work with the Oracle Java SDK. In this post we will see the steps we have to follow to install Oracle’s Java SDK in Debian Stretch.
Download the Java SE Development Kit from the oracle site. Oracle provides various download options: You need to check the option “accept license” and download the tar.gz file.
Now we are going to create a folder in /usr/local for the Java installation
Then, we need to extract the content of the tar file in our recently created /usr/local/oracle-java folder.
We can use this command to check the which java version we have installed. The same command can also be used to verify if our system it is defaulting to the Oracle’s java SDK:
In my case the output of the above command looked like this:
Here we see that although we have installed the Oracle’s java version, the system is still using the openJDK version as the default one. Time to change that.
We can run the following commands in the cli to set the oracle JDK as the default JVM:
Now, if we run the command to check the java version again, the output has changed to this:
If later on we want to change the java settings again, and make the OpenJDK the default version, we only need to run the following command:
And then we can simply select the JVM that we wish from the ones available:
Thanks for reading. If you find this tutorial useful you can click in the “follow” button at the end of the post to be notified of new posts.