×

Set Up the Environment in Java

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,

  1. Windows Operating System.
  2. Linux Operating System.
  3. Mac Operating System.

Windows Operating System

Steps for setting up the Java Environment in Windows Operating System are:

Step 1:

Download the latest version of the Java from the Oracle website

Step 2:

After the successful download of the Java run the .exe file to install the Java in the System.

Step 3:
Then go to Control Panel > System and Security > System

Set Up the Environment in Java
Set Up the Environment in Java

Step 2:

Then Click on the Advanced System Settings, it shows the window like

Set Up the Environment in Java

Then click on the Environment Variables which is in the bottom left corner of the Window.

Step 4:

After Clicking the Environment Variables, the window shows

Set Up the Environment in Java

In the System Variables , select the PATH and click on edit.

Set Up the Environment in Java

Step 5:

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.

Step 6:

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

Step1:

Open the Application and the go to the Accessories. Then Open the terminal.

Step 2:

Then run the command

sudo apt-get install openjdk-8-jdk

Step 3:

 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.)

Step 4:

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

Step 1:

Open the terminal in the Mac form the applications.

Step 2:

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.

Step 3:

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

ls -al

it shows the bash profiles present in the system. A new Bash Has to be created to set up the Environment variable.

Step 4:
For setting the Java variable , type the command

echo $JAVA_HOME

after running the command , if it shows the blank then the variable is not set.

Step 5:

To create the bash profile, type the command like

touch./bash_profile

Step 5:

Now edit the bash profile which created in the step 5. Then run the command

export JAVA_HOME = $(/user/libexec/java_home)

Step 6:

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.

Conclusion

By this, the setting of the Java environment in the different operating system is done.


Related Topics

Rehashing in Java

The most crucial idea mostly in the data structure is hashing, which is utilized to change a particular key into some other value. The hash function can be used to...

7 minutes read.

Java Final Keyword

In Java, the last keyword is used to limit the user. The applications of the java final keyword have large range of usage in program development. Last can be: variablemethodclass A final...

3 minutes read.

Java Math with Methods and Examples

Java Math class contains various methods for performing math operations like min(), max(), avg() and various trigonometric functions like sin(), cos(), tan() etc. Methods: The java.lang.Math class contains various methods for performing...

5 minutes read.

How to Iterate List in Java?

List is a Collection foundation interface in Java. It enables us to keep the collection of objects in order. The four classes that make up the List interface implementation are...

3 minutes read.

Java Extends vs Implements

Java: We known that the java is a pure object oriented programming language. Java programming language consists of many features such as portable, plat form independence, secured, robust, simple, architecture neutral,...

4 minutes read.

Java Project Ideas

When it comes to constructing projects, Java is regarded as one of the best languages and is also one of the most paid. Java excels in any application, whether it...

10 minutes read.

Features of Java

The objective of the Java programming language is to provide portability, security, and simplicity. In spite of this, Java has a number of features that makes it a popular language...

5 minutes read.

Java Try-Catch Block

Java Try Block The handling of the exceptions in a block of code is done with the help of java try block. It throws the code that is enclosed in a...

3 minutes read.

Program to Find the Common Elements between two Arrays in Java

In this article, we are going to learn how to find the common elements between two arrays using Java. Here, we use different approaches in Java to find the common...

3 minutes read.

Java 8 filters list

A stream with the components of this stream that match the given predicate is provided by the streaming filter (Predicate predicate). This process is step-by-step. Because these operations are always...

4 minutes read.

Insertion Sort in Java

Insertion Sort in Java Insertion sort in Java is a simple sorting algorithm that works in the same way as we hold cards in hand. Insertion sort does the sorting element-by-element,...

3 minutes read.

Java Create File

A File is a hypothetical way, which has no genuine presence. It is very much like while "using" that File that the major real activity of putting away something in...

5 minutes read.

Annotations in Java

Annotations in Java Java Annotations are metadata about the source code. They do not have any direct effect on the execution of the java program. Annotations in Java were introduced in...

4 minutes read.

Java StringReader Class

StreamReader Class technique enables character reading from a string. The java.io package contains this class. A string serves as a source in the character stream. While the Stream class is...

4 minutes read.

House Numbers in Java

In this section, we will discuss about house number in Java. It is a sum of cubes, each of which has a dimension of h + 1. There is a...

3 minutes read.

How to check the Java version in cmd

To make programs that can run on our systems, we need to install programming language-related software in our systems. Different programming languages require different types of software, aka IDEs (Integrated...

5 minutes read.

Ganesha’s Pattern in Java

This part teaches us how to use stars and other special characters to write Ganesha's Pattern in Java programming. Among the most challenging Java pattern applications to code. The Ganesha will be...

3 minutes read.

XNOR operator in Java

The opposite of the binary equivalent of XOR is given by XNOR. Truth table: XYXNOR001010100111 If the bits are the same, it returns 1, else it returns 0. Examples:  Input: 10 20 Output : 1 A Binary...

3 minutes read.

Java class class

Java Class class instances are an executing Java application's implementation of the classes and interfaces. As well as, every Array is indeed an object that is common for all Arrays...

6 minutes read.

Char and String differences in Java

Characters in Java Character (char) belongs to the characters group, which represents symbols in a character set, such as alphabets and numerals. A Java char has 16 bits in length and has a range...

5 minutes read.