First of all, we need to clarify what Java is. Java is a highly-targeted, object-oriented programming language designed in the early 1990s, launched on the commercial market in 1995.
Most applications distributed today are written in Java, and new technological developments allow it to be used on mobile devices like smartphones, embedded systems, and so on. This creates a unique platform, at the developer level, over an extremely diverse heterogeneous environment.
A compiled and correctly written Java program can be run without modification on any platform on which a Java virtual machine is installed.
The Java virtual machine is the environment in which Java programs run.
There are currently several JVM providers, including Oracle.
1) Java Virtual Machine or JVM is a virtual machine that provides the bytecode rolling environment. It is not tied up to the platform, meaning it has one implementation for each operating system. JVM is the heart of the Java programming language. When we run the program, JVM is responsible for transforming the bytecode into machine code. JVM is also platform independent and provides basic features such as Java memory management, garbage collection, and so on. We can also allocate a certain amount of memory to JVM. JVM is a virtual machine because it provides an interface that is independent of the operating system and hardware. This independence from hardware and the operating system gives Java programs the chance to run on any device without the need for changes.
2) Java Runtime Environment or JRE consists of JVM plus libraries and files that are used when executing a Java program. JRE is an accomplishment of JVM that provides a platform for running Java-programs. JRE includes Java Virtual Machine, binary files, and other classes. JRE does not contain development tools.
3) Java Development Kit or JDK consists of JRE plus other tools used to develop Java applications. The Java Development Kit is a major component of the Java environment and provides all the tools and executable binary files that are required for compiling, debugging, and executing the program in Java. JDK is a platform-dependent software so there are separate Windows, Mac and Unix-based installation programs. We can say that JDK is a superset of JRE because it contains JRE with Java-compiler, debugger, and base classes.
In conclusion, if you want to write a Java program, compile and then run it then you need JDK but if you want to run the program then JRE is enough.
How to Install Java with Apt-Get on Ubuntu 18.04
First of all, we need the following conditions met:
1) A machine installed with Ubuntu 18.04 server.
2) An administrator non-root user.
Then we can install JDK from Oracle.
1) First, we need to add the Oracle PPA, then update the package repository:
sudo add-apt-repository ppa: webupd8team / java
sudo apt-get update
2) Install JDK 9 by running the following commands:
sudo apt-get install oracle-java9-installer
3) Then we need to configure Java.
sudo update-alternatives -config java
Now that we have managed to install JDK, we can create the software that we are interested to develop.