Step to set JAVA_HOME in Linux
Use a text editor (vi or vim) to edit the .bash_profile file.
vim ~/.bash_profile
Add the following line to set the JAVA_HOME variable. Replace /path/to/java with the actual path to your Java installation directory
export JAVA_HOME=/path/to/java
export PATH=$JAVA_HOME/bin:$PATH
Save the filesacp :wq!) and exit the text editor.
apply the changes immediately, run the following command to reload the .bash_profile
source ~/.bash_profile
To verify that JAVA_HOME is set correctly, you can use the following command
echo $JAVA_HOME