Install JAVA on CentOS
In general, we need to uninstall the OPENJDK that comes with linux, and then install the sun jdk.
First, check whether the JDK that comes with Linux is installed.
Run the following command to view the installed JAVA version.
Linux code
- Java-version
Run the following command to view the JDK information.
Linux code
- Rpm-qa | grepjava
As shown in.
Uninstall installed JAVA, as shown in.
The uninstall is completed, as shown in.
Detach another one, as shown in.
The uninstall is completed, as shown in.
Step 2: Install SUN's JDK.
Official Website: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Create a java directory under/usr to install the java program in this directory. Enter the following command:
Linux code
- Mkdir/usr/java
Copy the downloaded installation file to the share folder of the original system and run the following command to view the file:
Linux code
- Cd/mnt/share
- Ls-
Copy the file to the/usr/java directory and enter the following command:
Linux code
- Cp *. gz/usr/java
Run the following command to view the/usr/java directory:
Linux code
- Cd/usr/java
- Ls-
As shown in.
Decompress the file and enter the following command:
Linux code
- Tar-xzvfjdk-7u13-linux-x64.gz
After decompression, a new directory jdk1.7.0 _ 13 will be generated under the/usr/java Directory, which stores the decompressed files.
For later setup convenience, we changed the directory jdk1.7.0 _ 13 to jdk. Enter the following command:
Linux code
- Mvjdk1.7.0 _ 13jdk
As shown in.
Alternatively, if the downloaded file is in rpm format, replace the tar command with the following command to install it. The other steps remain unchanged.
Linux code
- Rpm-ivhjdk-7u13-linux-x64.rpm
Finally, set the environment variables.
Enter the following command to enter the configuration file.
Linux code
- Vi/etc/profile
As shown in.
Go to the configuration file, as shown in. Delete the first line in the red box and change the configuration information of the following three lines.
Make environment variables take effect.
Execute the configuration file to make it take effect immediately. Enter the following command:
Linux code
- Source/etc/profile
Run the following command to verify whether the installation is successful:
Linux code
- Java-version
As shown in, the installation is successful!
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 it, as shown in.
Running successful!
If you download a java file at the end of bin, you can refer to: http://blog.csdn.net/cezeffort/article/details/7605863
Java: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html