1. first, obtain the resources. Download jdk from here. My jdk version is jdk1.6.0 _ 30, and jdk 1.6.0 _ 30 will be downloaded. binfile is placed in/usr/lib/jvm/java (if there is no java folder in/usr/lib/jvm, sudomkdirjava will enter this folder) 2. then, modify the binfile permission in shell to make it executable: sudochmodu + x/usr/lib/jvm/java/jd
1. First, obtain the resource
Download jdk from here
My version is jdk1.6.0 _ 30, and the jdk1.6.0 _ 30 will be downloaded. binfile is placed in/usr/lib/jvm/java (if there is no java folder in/usr/lib/jvm, sudo mkdir java after entering this folder)
2. Then, modify the binfile permission in shell,
Make executable:
Sudo chmod u + x/usr/lib/jvm/java/jdk1.6.0 _ 30.bin
Then run the Code:
Sudo./jdk-6u30-linux-i586.bin
After you press enter, subtitles will appear. Press enter until yes/no is required for the screen display. Enter y and press Enter. jdk will be decompressed to the folder to get the jdk 1.6.0 _ 30 directory.
3. Now, jdk has been installed. configure it below
Run the Code:
Sudo vi/etc/environment
In environment, the following section appears:
Reference:
PATH = "......:/usr/lib/jvm/java/jdk1.6.0 _ 30/bin"
CLASSPATH = ".:/usr/lib/jvm/java/jdk1.6.0 _ 30/lib"
JAVA_HOME = "/usr/lib/jvm/java/jdk1.6.0 _ 30"
4. At this time, the environment variables are successfully set (there are many ways to set the environment variables, not to list them one by one)
Because Ubuntu may have a default jdk, such as openjdk, we need to perform the following work to make the jdk installed by default.
Code:
Update-alternatives -- install/usr/bin/java/usr/lib/jvm/java/jdk1.6.0 _ 30/bin/java 300
Update-alternatives -- install/usr/bin/javac/usr/lib/jvm/java/jdk1.6.0 _ 30/bin/javac 300
Use the above two steps to add the jdk we installed to the java menu.
5. Select the default jdk
Code:
Update-alternatives -- config java
Two candidate items can be used to replace java (/usr/bin/java ).
Select the path priority status
------------------------------------------------------------
0/usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 automatic mode
1/usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
* 2/usr/lib/jvm/java-6-sun/bin/java 300 manual mode
To maintain the current value
Press ENTER or enter the selected number: 2
6. In this way, enter the code in shell:
Java-version
The system will display that the java used by the system is sun's java
Java version "1.6.0 _ 30"
Java (TM) SE Runtime Environment (build 1.6.0 _ 30-b12)
Java HotSpot (TM) Server VM (build between 5-b03, mixed mode)