On CentOS, the default is self-openjdk, and when executing java–version, you can see output similar to the following:
However, when you execute Javac, you are prompted to find the command you entered. The reason is that the CentOS default only comes with the OPENJDK runtime (JRE). If you need a JDK, you'll need to install it yourself. If you need Java development on Linux, you need to compile Java code, or do other related (such as Hadoop) development work, it is necessary to install the JDK.
So how do you install it? It's very simple, actually. As long as you execute the following command, it is usually OK:
Su-c "Yum Installjava-1.7.0-openjdk-devel"
After entering this command, the terminal will see a lot of output, but after seeing output similar to the following, it means that the installation is complete:
Of course, this time still can't execute javac. Don't forget to configure environment variables for the JDK!
OPENJDK the installed directory is located in/USR/LIB/JVM. If you enter this directory between the installation Openjdk_devel, you see the JRE folder, similar to the following:
And when you're done, this directory looks like this:
In the Bin folder below these Java directories, you will see the Javac command. This is the JDK.
you only need to open the environment variable file in the terminal Vim/etc/profile , fill in the appropriate directory:
Export Java_home=/usr/lib/jvm/java
Export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export path= $PATH: $JAVA _home/bin
This allows us to set up the JDK, which will take effect when the Source/etc/profile is entered.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
CentOS sets System variables for OPENJDK