1. Install JDK1 and download JDK. First download the latest JDK version from the Oracle website (currently JavaSEDevelopmentKit6u23) at http://www.oracle.com/technetwork/java/javase/downloads/index.html. After selecting the corresponding version of my system (My linux-32bit), we can see that there are two packages available to download, we want to go down is jd
1. Install JDK
1. Download JDK
Download the latest JDK version from the Oracle website (currently Java SE Development Kit 6u23) at http://www.oracle.com/technetwork/java/javase/downloads/index.html. After selecting the appropriate version with your own system (My is linux-32bit), you can see that there are two packages that can be downloaded, we want to go down to the jdk-6u23-linux-i586.bin.
2. Install JDK
(1) Place the downloaded package in the/usr/lib/jvm/sun-java directory, open the terminal, and enter the following command (do not forget the path ):
Sudo chmod + x jdk-6u23-linux-i586.bin, which adds execution permissions to bin-type files. You can run the ls-l command to view the execution permissions of files in the current directory.
(2) enter the following command:
Sudo./jdk-6u23-linux-i586.bin, also do not forget the path, you can first use the cd command in the previous step to enter the directory where the bin package is installed.
Then JDK will start automatic installation, until Press Enter to Continew..., Press the Enter key, Done! End installation.
3. Configure JDK
(1) Configure Environment Variables
Method 1:
The installed JDK generates a folder named jdk1.6.0 _ 23 in the current directory where the installation package is located.
Enter sudo gedit/etc/environment in the terminal and configure path, classpath, and JAVA_HOME in the pop-up editor.
PATH = "......:/home/star/bin/jdk1.6.0 _ 23/bin", colon is used to separate multiple environment variables;
CLASSPATH = "/home/star/bin/jdk1.6.0 _ 23/lib ";
JAVA_HOME = "/home/star/bin/jdk1.6.0 _ 23 ";
Save and exit.
Method 2:
Configure the environment variables and add the following content after/etc/profile:
# Set java environment
JAVA_HOME =/usr/local/jdk. (version)
Export JRE_HOME =/usr/local/jdk. (version)/jre
Export CLASSPATH =.: $ JAVA_HOME/lib: $ JRE_HOME/lib: $ CLASSPATH
Export PATH = $ JAVA_HOME/bin: $ JRE_HOME/bin: $ PATH
(2) Update the default JDK version.
Because java is a part of the linux system, you must reset it to make the system use the latest jdk by default.
Enter:
Sudo update-alternatives -- install/usr/bin/java/home/cy/jdk1.6.0 _ 23/bin/java 300
Sudo update-alternatives -- install/usr/bin/javac/home/cy/jdk1.6.0 _ 23/bin/javac 300
Add the JDK we installed to the java menu.
Enter:
Sudo update-alternatives -- config java, set the JDK used by the system by default. For example, manually add a higher priority
You can run the following command to check whether the operation is successful.
Code:
Java-version
If yes, the installation is successful!
Java version "1.6.0 _ 20"
Java (TM) SE Runtime Environment (build 1.6.0 _ 20-b02)
Java HotSpot (TM) Server VM (build 16.3-b01, mixed mode)