In general, we will have to uninstall the Linux openjdk, and then install the Sun's JDK.
Start the terminal (run in the virtual machine)
First check to see if the Linux-brought JDK is installed.
Enter the following command to view the installed Java version information.
java -version
Enter the following command to view the information for the JDK.
rpm -qa|grep java
Uninstall the already installed Java, as shown in. (Note: The TAB key can be added, sometimes the package name will be abbreviated, do not worry about spelling mistakes)
yum -y remove java-1.7.0-openjdk-1.7.0.75-2.5.4.2.el7_0.x
Removal success
Uninstall the other one, as shown in.
-y remove tzdata-java-2015a-1.el7.noarch
Delete Complete
Next, install the Sun's JDK GZ format
Official website: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
The WINSCP tool is created directly from a remote connection or can be created from the command line
Create a share under/mnt Currently, you can view all the files in the directory by ls-a the various resource files.
-a
Create a Java directory under/usr/local to install the Java program in this directory, and enter the following command:
mkdir /usr/local/java
Copy the JDK file to the/usr/local/java directory and view it and enter the following command:
cp jdk-8u91-linux-x64.gz /usr/local/java/ cd /usr/local-a
Unzip the file to the current directory and enter the following command:
-xzvf jdk-8u91-linux-x64.gz
After decompression, in the/usr/local/java directory will generate a new directory jdk1.8.0_91, which is stored in the extracted files.
For ease of Setup later, we have renamed the directory jdk1.8.0_91 to jdk-1.8 and entered the following command:
mv jdk1.8.0_91 jdk-1.8
Or, if the file you downloaded is in RPM format, replace it with the following command at the tar command above, and the other steps will be the same.
-ivh jdk-8u91-linux-x64.rpm
Finally, the environment variable is set.
Enter the configuration file by entering the following command.
vi /etc/profile
Enter the configuration file, as shown, to remove the first row in the red box and change the configuration information to the following three lines.
export JAVA_HOME=/usr/local/java/jdk-1.8export PATH=$JAVA_HOME/bin:$PATHexport CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
Then press the ESC key to end: wq! Save exit (remember to add a colon before)
Preparation:
"Colon", or ":" (without double quotes), a colon appears below, waiting for the input command
W:write, writing
Q:quit, exit
: wq! Save and exit
: Q Direct exit (Prerequisite: Document not changed)
: q! Do not save direct exit
:! Forced exit (not recommended)
Let the environment variable take effect.
Execute the configuration file so that it takes effect immediately and enter the following command:
source /etc/profile
To verify that the installation was successful, enter the following command:
java -version
(if command not found is displayed (commands not found) indicates that there is no Java-based soft link, see below)
Create a soft link to Java in the/sbin directory
At this point we enter the Java command in the shell, we will prompt the Java command is not found in/usr/bin, because we have not
$JAVA _home/bin/java to create a soft link in the/sbin directory
Create a soft link command to the/sbin/java directory
ln -s /usr/local/java/jdk-1.8/bin/java /sbin/java
As indicated by the completion
Report:
Running java-version without the relevant version information, the following error occurred:
DL failure on line 685error:failed/usr/local/jdk-1.8/jre/lib/i386/client/libjvm.so, because/usr/local/jdk-1.8/jre/ Lib/i386/client/libjvm.so:cannot Restore segment prot after Reloc:permission denied
Later through the query, it is the problem of SELinux setup.
The solution is as follows:
1. Open/etc/selinux/config
2. Change Selinux=enforcing to Selinux=disabled
3. Restart Linux
Run the first Java program.
Create a new Helloworld.java file as shown in.
Edit the file as shown in.
Save the file, compile and run as shown in.
Run successfully!
Linux-centos-7-64 bit: 1, install Java environment