I just started learning to use the Linux system in the past two days, and suddenly I thought of installing the Java operating environment on Linux, and then I used Linux to do the project. I searched a lot of methods on the Internet about how to install jdk, but many of them are not practical, here I summarize a bit
1. Here are two ways to install jdk, the easiest is to enter the following command in the case of networking
$sudo apt-get install openjdk-7-jdk
Then java -version to check the installation. But I didn't use it, because I found this method at the end (after knocking for an afternoon, this thing suddenly popped up on the web page, and I wanted to scold the street), as a linux novice, I am really bad enough.
The second method is to manually configure after downloading the installation package. I installed the jdk1.8.0_121 version. First, download jdk-8u121-linux-x64.tar.gz on the java official website.
Then enter the following command to unzip
$tar -zxvf jdk-8u121-linux-x64.tar.gz
You will get a jdk1.8.0_121 installation package, copy it to the /opt/software path with the following command
$cp jdk1.8.0_121 /opt/software
Then configure the environment variables and enter the command
$gedit ~/.bashrc
Paste the configuration at the end of the document
export JAVA_HOME=/opt/software/jdk1.8.0_121
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
Save (ctrl+s) and close
enter
$source ~/.bashrc
make the configuration take effect
You can now verify that the jdk installation was successful with the java -version command. If the version of jdk is displayed, then congratulations.
2. If the eclipse installation package is downloaded from the Internet, the steps to install jdk above are necessary. Download eclipse-jee-neon-2-linux-gtk-x86_64.tar.gz on the eclipse official website
then unzip
$ tar -zxvf eclipse-jee-neon-2-linux-gtk-x86_64.tar.gz
Get the eclipse file and copy it to the /opt/software directory
$cp eclipse /opt/software
Enter the eclipse file
$ cd eclipse
Execute the following command to run eclipse
$./eclipse
Now you can do projects with java code on linux!