Home > Article > Backend Development > How to install jdk in golang environment
With the wide application of golang, more and more developers are using golang for development. But sometimes we need to cooperate with other languages for development, such as Java. At this time, you need to install jdk in the golang environment. This article will introduce how to install jdk in golang environment.
1. Preparation work
Before installing jdk, you need to ensure that the golang environment has been set up and is running correctly. If the golang environment has not been installed, please refer to the official documentation to install it.
2. Download jdk
Download the appropriate version of jdk from the oracle official website. The download address is: https://www.oracle.com/java/technologies/javase-downloads.html
3.Install jdk
Extract the downloaded jdk file to your local computer, and remember the name of the decompressed folder. Assuming that the name of the decompressed folder is jdk-11.0.9, you can install it according to the following steps:
$ cd /usr/local $ sudo chown -R $(whoami) /usr/local $ tar -xzf ~/Downloads/jdk-11.0.9_linux-x64_bin.tar.gz
4. Configure environment variables
After the installation is completed, you need to configure the environment variables. This can Achieved by modifying the ~/.bashrc file:
$ export JAVA_HOME=/usr/local/jdk-11.0.9 $ export PATH=$JAVA_HOME/bin:$PATH
5. Test
In order to verify whether jdk is successfully installed, we can use the following command to verify:
$ java -version
If the following information is returned, then Indicates that the installation is successful:
openjdk version "11.0.9" 2020-10-20 OpenJDK Runtime Environment (build 11.0.9+11) OpenJDK 64-Bit Server VM (build 11.0.9+11, mixed mode)
6. Notes
7. Summary
Through the above steps, we can successfully install jdk in the golang environment and configure the corresponding environment variables. This allows us to use Java for development in the golang environment and improve work efficiency.
The above is the detailed content of How to install jdk in golang environment. For more information, please follow other related articles on the PHP Chinese website!