OpenJDK is an open source community version of Java. It is widely used because it is available by default on Ubuntu and many Linux distributions. However, you cannot use it to develop commercial applications. If you are a Java developer or you are a beginner, then, this is for you, because I will teach you how to install Oracle Java in Ubuntu and Debian.
First, let’s talk a little Java. Java is an Object Oriented programming language owned by Oracle. It is a compiled language, with its own rules and widely spread at educational and professional levels.
It is composed of three fundamental parts: JDK, JRE, and JVM. JDK is the Java development kit which contains the compiler and libraries needed to start creating applications with Java. The Java Runtime Environment (JRE) is the engine for running these applications. Last, the Java Virtual Machine (JVM) functions as an intermediate layer between the JRE and the operating system where Java applications run.
Java and Linux
Java is compatible with Linux, this means that it is possible to run, and build applications from your favorite distribution. The problem is that the version in the official repositories is based on OpenJDK. In short, this means that we will not be able to use it to create commercial applications, besides it is a community version with the advantages and disadvantages that it can present.
That’s why if you want to develop applications for third parties without having licensing problems, you should install Oracle Java.
Install Oracle Java thanks to a PPA
As I said before, installing Oracle Java is necessary if you are a developer. Fortunately, it is possible to do it in a quite simple way thanks to the Java Uprising PPA.
This repository automates the process of downloading, installing and configuring Oracle Java as a .deb package. Obviously, it downloads it from the Oracle website, configures it and allows us to set a default version.
For Ubuntu 18.04 and 18.10
First, you need to update the system.
:~$ sudo apt update && sudo apt upgrade
Once the installation is complete, the next step will be to add the java uprising repository.
:~$ sudo add-apt-repository ppa:linuxuprising/java
Finally, you can install Oracle Java. Then, you will see the license terms.
:~$ sudo apt install oracle-java12-installer
It’ll take a while, according to your internet connection.
Set Oracle Java 12 as default
This PPA brings with it a distributed tool in the form of a very useful package to set Oracle Java 12 as the default Java version of the system.
If you use Ubuntu the package oracle-java12-set-default
has been installed as a recommended package in the installation of oracle-java12-installer
package and it is not necessary to do anything else except verifying the installation.
:~$ java --version
On the other hand, if you want to install Java 12 but not the default one. So, you have to remove the oracle-java12-set-default
package.
:~$ sudo apt remove oracle-java12-set-default
That’s it.
Conclusion
It is quite simple to install the proprietary version of Java, on Ubuntu and Debian, but if you are interested in learning about this programming language then you must do so.
Tell us your experience, do you use Java? Are you a Java developer? Tell us in the comments
Please spread this article through your social networks.
You can also read “5 very interesting plugins for netbeans“