How to configure the jdk environment under Linux

  • 2021-01-22 08:15:14
  • OfStack

1. Go to the jdk website to download the jdk package for linux, such as jdk-8u162-linux-x64.tar.gz

2. Create a directory to jdk package copy to the directory, such as home/haha/user/java

3. Enter the directory in the console and unzip tar zxvf jdk-8u162-linux-x64.tar.gz

4. Configure environment variables:

Open the console, run sudo vi /etc/profile, insert the following configuration contents into the file, then save to exit (press esc first, then :wq)


 JAVA_HOME=/home/haha/user/java/jdk1.8.0_162
 PATH=$JAVA_HOME/bin:$PATH
 CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
 export JAVA_HOME
 export PATH
 export CLASSPATH

5. Run source /etc/profile to make the environment effective

6. Enter java -version at the terminal to see if it succeeds (the corresponding version number will appear if it succeeds).

conclusion

The above is this site to introduce the Linux configuration jdk environment, I hope to help you, if you have any questions welcome to give me a message, this site will reply to you in time!


Related articles: