To set the JAVA_HOME
and PATH
variables under the Linux Bash profile, you can edit the ~/.bashrc
file and add the following lines:
export JAVA_HOME=/path/to/java export PATH=$PATH:$JAVA_HOME/bin
Replace /path/to/java
with the path to the Java installation directory on your system.
To apply the changes, you can either log out and log back in or run the following command:
source ~/.bashrc
This will set the JAVA_HOME
and PATH
variables in the current Bash shell. The changes will be applied to all new Bash shells that you open.
The JAVA_HOME
variable specifies the location of the Java installation on your system. It is used by many Java-based applications to locate the Java runtime and other Java libraries.
The PATH
variable is a list of directories that are searched by the shell when you run a command. By adding the $JAVA_HOME/bin
directory to the PATH
variable, you can run Java commands from any location on your system.
Keep in mind that the ~/.bashrc
file is executed whenever you start a new Bash shell. If you want the changes to be applied to all users on the system, you can edit the global /etc/bashrc
file instead. However, be aware that changes made to the global bashrc
file will apply to all users on the system, so use caution when modifying this file.