Java is a versatile, object-oriented programming language developed by Sun Microsystems (acquired by Oracle Corporation). It is designed to be platform-independent, allowing developers to write code that can run on any device or platform with a Java Virtual Machine (JVM). Java is widely used for building a variety of applications, including web, mobile, enterprise, and embedded systems.
Java Development Kit (JDK) and Java Runtime Environment (JRE) are essential components of the Java platform, each serving a specific purpose in the development and execution of Java applications.
The JDK is a software development kit that provides tools, executables, and binaries required for developing, compiling, and running Java applications. It includes the Java Compiler(javac), Java Virtual Machine (JVM), various development tools, and an extensive set of libraries and APIs.
Java Compiler (javac) : Translates Java source code into Java bytecode..
Java Virtual Machine (JVM) : Executes Java bytecode on the target hardware.
Development Tools : Includes tools for debugging (jdb), documentation generation (Javadoc), and packaging (jar).
Developers use the JDK during the software development phase to write, compile, and test Java applications. It provides everything needed for the entire development life cycle.
The JRE is a subset of the JDK and provides the runtime environment for Java applications. It includes the JVM, class libraries, and other supporting files needed for the execution of Java applications.
Java Virtual Machine (JVM): Executes Java bytecode.
Class Libraries: A set of precompiled classes and methods that Java applications can use for common tasks.
End-users who only need to run Java applications use the JRE. Itdoesn't include development tools like the compiler or debugger.
The JDK includes the JRE, meaning that if you install the JDK, you also have everything in the JRE. However, the reverse is not true—the JRE doesn't include development tools.
Developers use the JDK during the development phase to create and test applications. End-users only need the JRE to run applications.
In summary, the JDK is a comprehensive package for Java development, including tools and libraries for both development and execution, while the JRE is a runtime environment for end-users, containing only what is necessary to run Java applications.
This guide is predicated on the assumption that you are using an Ubuntu 22.04 server. But don't worry if your server is running a different operating system, the commands and concepts are still mostly applicable.
To start with installation let's first update your apt package index in your Linux:
Also, we need to check whether Java is already installed or not
Let’s install JRE from OpenJDK:
Now you can verify the installation:
You'll get the output shown below:
By default, Elasticsearch listens on localhost and port 9200. Modify settings such as network.host and http.port if needed.
Initiate the Elasticsearch service using systemctl and allow a brief startup period to avoid connection errors:
To compile and run any specialized Java-based software, you might also require the JDK in addition to the JRE. Use the following command to install the JDK, which will also install the JRE:
Jdk installation can be verified bychecking version of java compiler:
You'll get the output shown below:
You can run the command below to set up multiple Java installations on a server and set up different Java versions using the command line.
Note: This command can also be used with the following other commands: key tool, java doc, and jarsigner, among others.
If you are running multiple versions use this command to find the path of the installation.
If you are not running multiple versions use this command to find the path of installation.
By running this command you will find output like this:
In my case java installation path is below : /usr/lib/jvm/java-11-openjdk-amd64
Take a copy of the path from the installation you like. Following that, use nano or another text editor of your choice to open /etc/environment:
At the end of file you can add path as
In this case it will be
Save the file now, and then exit the editor.
We must execute the following command to make the modifications made in the current session visible:
To verify your changes run the following command :
Output : /usr/lib/jvm/java-11-openjdk-amd64
Portfolio
Recent
Projects
Explore Projects