The Java is regarded as the pure object-oriented programming language. The Java applications are first compiled into the byte-code and then run by using the JVM. The Java is the platform independent i.e., it doesn’t depend on the in which operating system we are writing or running the code. The Java consists of three important components they are JVM, JRE and JDK.
Java Virtual Machine(JVM):
The JVM stands for Java Virtual Machine which consists of the runtime environment where is Java code can be executed.
Java Runtime Environment(JRE):
The JRE stands for the Java Runtime Environment, it contains the set of libraries which are used in the writing the code. The JRE is the Subset of the JDK.
Java Development Kit(JDK):
The JDK stands for the Java Development Kit, it contains the developer tools like Java compiler, jar, debugger etc.
For Setting up the environment in the Java in the different operating system,
- Windows Operating System.
- Linux Operating System.
- Mac Operating System.
Windows Operating System
Steps for setting up the Java Environment in Windows Operating System are:
Download the latest version of the Java from the Oracle website
After the successful download of the Java run the .exe file to install the Java in the System.
Then go to Control Panel > System and Security > System
Then Click on the Advanced System Settings, it shows the window like
Then click on the Environment Variables which is in the bottom left corner of the Window.
After Clicking the Environment Variables, the window shows
In the System Variables , select the PATH and click on edit.
There are various path in that section. Now click on the NEW button and the add the path where the Java is Installed. By default the Java is installed in the “C:\Programfile\Java\jdk\bin” . Add this path to new Path in the Environment variables.
Then Click on the Ok button which is on the bottom of the window and the setting of the Environment in Java is done in the Windows Operating System.
To check whether the Java is installed type the command ‘’javac-version”. It shows the current version of the Java which is installed in the system or else it Shows the “javac is not recognized as the internal or external command”.
Linux Operating System.
In the Linux operating system the simple way of installing Java is by installing the OpenJDK. It is a free open-source for Java Programming language. Steps for Setting the Environment for Java in Linux operating system are
Open the Application and the go to the Accessories. Then Open the terminal.
Then run the command
sudo apt-get install openjdk-8-jdk
For the Environment Variable, run the command
export JAVA_HOME = /user/lib/jvm/java-8-openjdk
in the terminal with the path in which the java is installed.(The above command is for the default path in which the java is installed.)
For setting the path for environment type the command
export PATH = $PATH:/user/lib/jvm/java-8-openjdk/bin
(The above command is for the default path in which the java is installed.)
After the successful of the all the above steps , then the Java Environment for Linux operating system is done.
MacOS Operating System:
To set up the Java environment in the Mac Operating System the follow the following steps
Open the terminal in the Mac form the applications.
To check if the Java is installed or not type the command
$ java - version
If the java is installed then it shows the version of the Java installed in the System.
After the successful completion of installing java in the Mac Operating system , then the Environment variable is to be set. To set the Environment variable type the command
it shows the bash profiles present in the system. A new Bash Has to be created to set up the Environment variable.
For setting the Java variable , type the command
after running the command , if it shows the blank then the variable is not set.
To create the bash profile, type the command like
Now edit the bash profile which created in the step 5. Then run the command
export JAVA_HOME = $(/user/libexec/java_home)
To verify the whether the Bash profile is installed , run the commands like
Java Virtual Machine(JVM):
It shows the path where it is installed.
By this, the setting of the Java environment in the different operating system is done.