1. Download the installation file from the official website (http://www.Oracle.com/technetwork/java/javase/downloads/jdk6u35-downloads-1836443.html) (such as: jdk-6u33-linux-x64.bin ). Copy the file to/usr/lib/java. If there is no java folder, create it. By default, the security file has no execution permission. Therefore, the first step is to grant the executable permission to the installation file.
1. Download the installation file from the official website (http://www.Oracle.com/technetwork/java/javase/downloads/jdk6u35-downloads-1836443.html) (such as: jdk-6u33-linux-x64.bin ). Copy the file to/usr/lib/java. If there is no java folder, create it. By default, the security file has no execution permission. Therefore, the first step is to grant the executable permission to the installation file, you can do this by running $ sudo chmod u + x/usr/lib/java/jdk-6u33-linux-x64.bin.
2. After Successfully modifying the permissions of the Installation File, run the command $ cd/usr/lib/java/to enter the java directory and then run the command $. /jdk-6u33-linux-x64.bin, the screen will appear installation tree, and finally need to enter the carriage return, when the press the Enter key prompt installation is complete. The current directory contains an additional jdk 1.6.0 _ 33 Directory, which means that jdk has been installed successfully.
3. After successfully installing JDK, We will configure JDK. Run the $ sudo gedit/etc/environment command to modify the environment file and add the following code:
PATH = "/usr/lib/java/jdk1.6.0 _ 33/bin"
CLASSPATH =.: $ java_home \ lib \ tools. jar: $ java_home \ lib \ dt. jar
JAVA_HOME = "/usr/lib/java/jdk1.6.0 _ 33"
If the PATH already exists, use the colon as the interval and add the bin directory address of jdk. In this way, the java environment variable is configured successfully, so that the jdk we installed is used by default, you also need to execute the following command:
Sudoupdate-alternatives-install/usr/bin/java/usr/lib/java/jdk1.6.0 _ 33/bin/java 300
Sudo update-alternatives-install/usr/bin/javac/usr/lib/java/jdk1.6.0 _ 33/bin/javac 300
Sudo update-alternatives -- config java
4. Run the command successfully. The JDK we installed is the default one. Then, run the java-version command to view the JDK information:
Java version "1.6.0 _ 33"
Java (TM) SE Runtime Environment (build 1.6.0 _ 33-b04)
JavaHotSpot (TM) 64-Bit Server VM (build between 8-b03, mixed mode)
5. Configure classpath and modify the environment variables of all users
$ Sudo gedit/etc/profile
Add at the end of the file
# Set java environment
JAVA_HOME =/usr/lib/java/jdk1.6.0 _ 33
Export JRE_HOME =/usr/java/jdk1.6.0 _ 33/jre
ExportCLASSPATH =.: $ JAVA_HOME/lib: $ JRE_HOME/lib: $ CLASSPATH
Export PATH = $ JAVA_HOME/bin: $ JRE_HOME/bin: $ PATH