The detailed tutorial for installing OpenJDK on Ubuntu 22 system is as follows:
Update system:
Open the terminal and execute the following command to update the system package:
sudo apt update sudo apt upgrade
Install OpenJDK:
Execute the following command to install OpenJDK 11:
sudo apt install openjdk-11-jdk
If you need to install other versions of OpenJDK, you can replace the version number in the above command. For example, to install OpenJDK 8, you can use the following command:
sudo apt install openjdk-8-jdk
Verify installation:
After the installation is complete, execute the following command to verify the installation of OpenJDK:
java -version
If the output displays Java version information, the installation is successful.
Configure environment variables (optional):
Open the terminal and execute the following command to edit the environment variable configuration file:
sudo nano /etc/environment
Add the following lines at the end of the file, where/usr/lib/jvm/java-11-openjdk-amd64
is the installation path of OpenJDK. If you are installing other versions of OpenJDK, please Adjust the path accordingly:
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"PATH="$PATH:$JAVA_HOME/bin"
Execute the following command to make the environment variables take effect:
source /etc/environment
Verify environment variable configuration (optional):
Execute the following command to verify whether the environment variable configuration takes effect:
echo $JAVA_HOME
Now, you have successfully installed OpenJDK on your Ubuntu 22 system. You can use Java commands to execute Java programs and perform Java development.
The above is the detailed content of Detailed tutorial on installing OpenJDK on Ubuntu22 system.. For more information, please follow other related articles on the PHP Chinese website!