tar.gz
Http://www.cnblogs.com/memory4young/p/ubuntu-install-jdk.html
How to install JDK under Linux, take Ubuntu as an example.
First, download
First of all, of course it is to download.
Address: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Select a different version as needed. The author chooses the jdk-7u45,
Second, decompression
Unzip the downloaded. tar.gz file.
Use the following command to extract:
Tar zxvf./jdk-7u45-linux-x64. tar.gz
For ease of administration, you can move the extracted files to another folder.
You can do it without doing it.
The author moved the file to the/opt/java/jdk/directory.
To facilitate the next set of environment variables, change the folder to a short name--jdk1.7
You can rename a folder by using the following command
MV Jdk1. 7.0_45/jdk1. 7/
Third, set environment variables
Edit the. bashrc file.
Enter the following command at the terminal:
VI ~/.BASHRC
At the end of the file, add the following lines of code:
Export JAVA_HOME=/OPT/JAVA/JDK/JDK1. 7Export classpath=${java_home}/libexport path=${java_home}/bin: $PATH
In order for the changes to take effect immediately, execute the following command at the terminal:
SOURCE ~/.BASHRC
P.S. It is best to back up the backup command before modifying the. bashrc file:
CP. BASHRC. bash_original
Iv. Verification
With the above steps, the JDK is installed.
Enter the following command to verify the java-version ,
The bin file is downloaded
- Cd/usr/lib
- sudo mkdir java
- CD Java
- CP ~/jdkxxx.bin/usr/lib/java/
- sudo chmod a+x jdkxxx.bin
- sudo./jdkxxx.bin
Jdkxxx.bin is the file name of the download, ~/jdkxxx.bin is the path to save the downloaded file. The first time you execute sudo, you need to enter the root password and enter it.
In the end, you'll see a done. Indicates that the installation is complete.
2) Configure Environment variables: Open the/etc/profile file and add the following paragraph at the bottom of the file:
- Export java_home=/usr/lib/java/jdk1.6.0_29
- Export path= $JAVA _home/bin: $PATH
- Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $CLASSPATH
Where/usr/lib/java/jdk1.6.0_29 is the installation root directory of the JDK. Command:
- sudo gedit/etc/profile
Ctrl+s save Close, then:
- sudo source/etc/profile
Make the environment variable configuration effective so that you do not have to restart. However, only valid at the current terminal, if you open a terminal again, you need to do it again.
Finally, enter the command to check if the configuration was successful:
- Java-version
If the configuration succeeds, the version number of the JDK appears, as shown in:
Linux installation jdk RPM version step
1, first download the JDK from the Internet (jdk-7u1-linux-i586.rpm),: http://www.oracle.com/technetwork/java/javase/downloads/ jdk-7u1-download-513651.html, downloaded and placed in the/home directory, of course, the other place is OK.
2. Enter the installation directory
#cd/Home
#cp jdk-7u1-linux-i586.rpm/usr/local
#cd/usr/local
Add executable permissions to all users
#rpm-IVH jdk-7u1-linux-i586.rpm
Installation process:
3. Setting Environment variables
#vi/etc/profile
When open, add the following environment variable configuration code at the bottom of the document:
Export java_home=/usr/java/javajdk1.7.0_01
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export path= $JAVA _home/bin: $PATH
Note:export path= $JAVA _home/bin: $PATH, pay attention to putting $path to the last. To avoid problems with old and new versions.
4. Check if the JDK is installed successfully.
#java-version
If you see the JVM version and related information, the installation is successful!
-----------Split Line-----------------
When you have successfully installed the javajdk1.7.0_01 into the/usr/java, and configured the system environment variables
Execute # java-version When the javajdk1.7.0_01 is displayed because your Linux system has a default JDK;
1.# Cd/usr/bin
# ln-s-f/usr/java/javajdk1.7.0_01/jre/bin/java
# ln-s-f/usr/java/javajdk1.7.0_01/bin/javac
2, then uninstall javajdk1.7.0_01, re-install again. Uninstall method:
Check the JAVAJDK1.7.0_01 package name first
#rpm-qa | grep JDK
Then execute
#rpm-E Jdk-1.7.0_01-fcs
When you are finished uninstalling, reinstall jdk-7u1-linux-i586.rpm again.
===============
Linux installation JDK