×

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

Method Overloading In Java

If the same class consists of different methods with the same name and the methods can vary by different number of parameters then it is known as Method Overloading. Method...

2 minutes read.

How to Convert int to double in Java

How to Convert int to double in Java When two variables of different types are involved in the single expression, Java compiler uses built-in library function to convert the variable to...

2 minutes read.

If Condition in Lambda Expression Java

The new and significant lambda expression feature of Java was added in Java SE 8. It provides a clear and concise mechanism for describing a single-method interface using an expression....

4 minutes read.

Java Integer toUnsignedLong() method

The toUnsignedLong() method of Java Integer class returns a long value by simply converting the given argument to long after an unsigned conversion. Syntax public static long toUnsignedLong (int  x) Parameters The parameter ‘x’...

1 minute 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.

String Handling Method in Java

What is a String? Strings are a bundle of different characters that are normally used in Java programming language. Strings are regarded as objects in the Java programming language. “String” is a...

4 minutes read.

Java LDAP Authentication

WHAT IS LDAP? Clients can communicate with directory services by sending requests and receiving responses using the Lightweight Directory Access Protocol (LDAP). The term "LDAP server" refers to a directory service...

7 minutes read.

Static Array in Java

In this tutorial, we will study static arrays in Java. An array is a data structure that is of great importance in any programming language. It is classified into two...

3 minutes read.

Java Wrapper classes

Java Wrapper classes A wrapper class is a class whose object contains a primitive data type; moreover it provides a way to use primitive data type (int, boolean, etc.) as objects. Wrapper...

2 minutes read.

Properties Class in Java

Properties class is associated with Java since JDK 1.0, i.e. it is a legacy class. It is the subclass of Hashtable. It is used to maintain the lists of values in which...

5 minutes read.

Java Math sqrt() Method

The sqrt() method of Java Math class returns the accurately rounded positive square root of the specified double value. Syntax: public static double sqrt(double a) Parameters: The parameter ‘a’ represents the number whose square...

2 minutes read.

Java FileOutputStream

What is FileOutputStream?When we need raw stream data written into a file, we need to look for another option: FileOutputStream. It is used when the file's data is byte-oriented. It comes under...

4 minutes read.

Packages Program in java

Let us know what package is in the Java programming language, and later we will learn about types of packages and how to define a package. How to import Java...

4 minutes read.

Java 9 Try With Resources

Java 9 provides the improvement in the try statement. It allows us to declare a try statement with duly declared resources. Whenever the user does not require the functionality with...

3 minutes read.

PriorityBlockingQueue Class in Java

What is the Queue? An abstract data structure like Stacks is a queue. A queue is open on both ends. Data is always pushed to one end, called enqueue, and removed...

4 minutes read.

Balanced Parentheses in Java

One of the frequent programming issues, commonly referred to as the Balanced brackets issue, is the problem with the balanced parenthesis. Interviewers frequently provide this task, in which we must...

5 minutes read.

How to Convert String to double in Java

How to Convert String to double in java It is used if we have to perform mathematical operations on the string that contains a double number. When we get data from...

3 minutes read.

Menu Driven Program in Java

Menu Driven Program in Java The menu-driven program in Java is a program that displays a menu and then takes input from the user to choose an option from the displayed...

3 minutes read.

Java Integer decode() method

The decode() method of Integer class decodes a String into an Integer. It can accept decimal, hexadecimal and octal numbers. Syntax public static Integer decode(String nm) throws NumberFormatException Parameters The parameter ‘nm’ represents the...

2 minutes read.

Java Integer toUnsignedString() method

The toUnsignedString() method of Java Integer class returns a string representation of the argument as an unsigned decimal value. The second syntax returns a string representation of the given argument as...

2 minutes read.