How To Set Java_home In Linux Server
In this article, we'll learn to fix the JAVA_HOME variable in Linux. JAVA_HOME should be correctly assault your system in society for you to exist able to run Java programs successfully. In example in that location is an mistake, you will get the following error :
Error: JAVA_HOME is not defined correctly. We cannot execute /usr/java/jdk1.7.0_05/bin/java
To avert getting this error you will take to set your JAVA_HOME path. This is a footstep past step tutorial near how you lot can exercise that. The process is slightly different for setting it for a single user and all users. We will get over both in this tutorial.
Fix the JAVA_HOME variable for a single user
Permit's offset past checking if JAVA_HOME contains the right path or not. You tin can display the path using :
If information technology contains a path, y'all volition meet the output. In case the variable is empty, you lot volition not get an output. If the output is empty yous can proceed with the steps beneath to set up it.
1. Install Java on Linux
The outset stride is to make certain that you have Java installed on your organisation. To check the version of java installed run the following command:
2. Open .bashrc file
The .bashrc file is a bash shell configuration file. Information technology is stored at ~/.bashrc and gets executed every fourth dimension a user starts up a fresh terminal session in interactive style on their Linux system. Surround variables are stored in this file.
To open this file use the vim editor.
To edit in vim press 'i'.
In one case you lot are in insert mode add the following line to the file.
export JAVA_HOME=/usr/java/jre1.8.0_04
Make certain y'all utilise the right java version in the argument in a higher place.
iii. Source ~/.bashrc
Run the source command as shown below to brand sure that the changes are reflected.
4. Print JAVA_HOME
You can bank check if the path was correctly set by using the echo command.
Set the JAVA_HOME variable for all users
The steps to set JAVA_HOME variable for all users are similar to setting information technology for a single user. You lot will need to log in as root or execute the commands using the sudo command.
1. Open /etc/bashrc file
Changes in global configurations are done by editing the /etc/bashrc file. You tin can open up the /etc/bashrc file using the command:
To edit in vim press 'i'.
Add the post-obit line:
export JAVA_HOME=/usr/java/jre1.viii.0_04
Make sure y'all use the right java version.
2. Run source /etc/contour
To make sure that the changes are reflected immediately use the source command as follows:
This will successfully update the path in JAVA_HOME variable.
3. Print JAVA_HOME
To check if the path was set successfully use:
Conclusion
This tutorial covered the steps to update the JAVA_HOME variable in Linux. Y'all can read through this tutorial to learn how to install Java in Linux. Continue to follow LinuxForDevices for more than tutorials on Linux.
How To Set Java_home In Linux Server,
Source: https://www.linuxfordevices.com/tutorials/linux/set-the-java-home-variable
Posted by: penaantemblowind.blogspot.com
0 Response to "How To Set Java_home In Linux Server"
Post a Comment