How to install java on linux system
This article introduces the knowledge of "how to install java on linux system". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
How to install java (jre or jdk) on ubuntu server, mainly pay attention to the following points: (also applicable on CentOS,RedHat)
1. Download the java version you want.
JRE download: http://java.com/en/download/manual.jsp;(generally download JDK directly)
JDK Download: www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
2. Assuming you downloaded jdk, copy the jdk archive jdk-8u131-linux-x64.tar.gz to/usr/lib/jvm. If there is no such folder, it will be automatically created:
cp jdk-8u131-linux-x64.tar.gz /usr/lib/jvm
Switch to/usr/lib/jvm and extract it in that directory:
cd /usr/lib/jvmtar xf jdk-8u131-linux-x64.tar.gz
3. Modify environment variables:
#vim ~/.bashrc
#Add the following (#sign not required in VIM)
#export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_131
#export CLASSPATH=.:$ {JAVA_HOME}/lib:${JRE_HOME}/lib
#export PATH=${JAVA_HOME}/bin:$PATH
#Save and make it effective
#source ~/.bashrc
4. Configure default programs
#update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_131/bin/java 50
# update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_131/bin/javac 50
# update-alternatives --config java
#If you have other jdk installed in your system, the system will prompt you, select jdk1.8.0_131
Note: If you install jre, just configure the first item above, that is: java
5. Test installation is complete
#java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
If the correct version information appears, such as java version jdk1.7.0_17, the installation is complete;
If the following results appear, there is a problem with the installed version, such as 32-bit java installed on a 64-bit system.
-bash: /usr/bin/java: No such file or directory
This problem can be solved by the following command:
sudo apt-get install libc6-i386
When you use java -version again, the correct version information appears.
Now that the Java environment is fully configured, you can happily write Java programs.
"How to install java on linux system" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!