How can I change the JDK environment variable in Linux and make it take effect?

To modify the JDK environment variables on Linux and make them effective, you can follow these steps:

  1. Open the terminal window.
  2. Open the ~/.bashrc file using a text editor like vi or nano.
vi ~/.bashrc
  1. the JDK located in /usr/local
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
  1. Save the file and close the text editor.
  2. Execute the following command to make the modified environment variables take effect:
source ~/.bashrc

The JDK environment variable has now been modified and is effective. You can input the java -version command in the terminal window to verify if the JDK has been correctly installed and the environment variable has been set.

bannerAds