Install jdk1.6 in Linux
1. Go to the http://java.sun.com/j2se/1.4.2/download.html to download a Linux platform JDK, it is recommended to download RPM self-extract format (rpm in self-extracting file, j2sdk-1_4_2_06-linux-i586-rpm.bin );
2. Upload the file to a Linux server and run the following command in shell:
[Root @ linuxserver RPM] # chmod 755 j2sdk-1_4_2_06-linux-i586-rpm.bin [Root @ linuxserver RPM] #./j2sdk-1_4_2_06-linux-i586-rpm.bin |
There will be a piece of Sun Protocol, several times the Space key, when asked whether to agree, you can press Yes.
Sun Microsystems, Inc. Binary Code License Agreement For Javatm 2 software development kit (j2sdk), Standard Edition, version 1.4.2 _ x ... Do you agree to the above license terms? [Yes or No] Yes Unpacking... Checksumming... 0 0 Extracting... Unzipsfx 5.40 of 28 November 1998, by Info-zip (Zip-Bugs@lists.wku.edu ). Inflating: j2sdk-1_4_2_06-linux-i586.rpm Done. |
3. The program will automatically generate a j2sdk-1_4_2_06-linux-i586.rpm file, which is the main package, to install below;
[Root @ linuxserver RPM] # rpm-IVH j2sdk-1_4_2_06-linux-i586.rpm Preparing... ######################################## ### [100%] 1: j2sdk ####################################### #### [100%] |
4. Set Environment Variables
Usually, you prefer to use the Export command to directly set it in shell.
[Root @ linuxserver RPM] # export java_home =/usr/Java/j2sdk1.4.2 _ 06 [Root @ linuxserver RPM] # export classpath =.: $ java_home/lib/dt. jar: $ java_home/lib/tools. Jar [Root @ linuxserver RPM] # export Path = $ path: $ java_home/bin |
Of course, this setting of environment variables takes effect only for the current shell. If you log on from another shell, you cannot use the variable you just set. So the best way is to modify the. bashrc file.
[Root @ linuxserver RPM] # vi. bashrc Set java_home =/usr/Java/j2sdk1.4.2 _ 06 Export java_home Set Path = $ path: $ java_home/bin Export path Set classpath =.: $ java_home/lib/dt. jar: $ java_home/lib/tools. Jar Export classpath |
Of course, you can also change the/etc/profile. However, this setting is not recommended because it will take effect for your shell and affect system security. Next, verify whether the variable settings take effect (log out before verification, and then log on again );
[Root @ linuxserver RPM] # echo $ java_home /Usr/Java/j2sdk1.4.2 _ 06/ [Root @ linuxserver RPM] # echo $ classpath /Usr/Java/j2sdk1.4.2 _ 06/lib/dt. jar:/usr/Java/j2sdk1.4.2 _ 06/lib/tools. Jar [Root @ linuxserver RPM] # echo $ path /Usr/Java/j2sdk1.4.2 _ 06/bin/:/usr/Kerberos/sbin:/usr/Kerberos/bin:/usr/local/sbin:/usr/local/bin: /sbin:/bin:/usr/sbin:/usr/bin:/usr/x11r6/bin:/root/bin [Root @ linuxserver RPM] # Java-version Java version "1.4.2 _ 06" Java (TM) 2 Runtime Environment, Standard Edition (build 1.4.2 _ 06-b03) Java hotspot (TM) Client VM (build 1.4.2 _ 06-b03, mixed mode) |
5. Set the environment to OK to see if JDK works normally. Let's write a test file test. java.
[Root @ linuxserver RPM] # VI test. Java Class Test { Public static void main (string [] ARGs) { System. Out. println ("Hello world! "); } } |
Save and exit. Compile and execute the command below;
[Root @ linuxserver text] # javac test. Java [Root @ linuxserver text] # Java Test Hello world! |
OK. The operation is normal.
6. To allow a user to run Java commands, modify the bash initialization file.
For example, to grant longware the permission to run Java commands,
[Root @ linuxserver root] # vi/home/longware/. bashrc Set java_home =/usr/Java/j2sdk1.4.2 _ 06 Export java_home Set Path = $ path: $ java_home/bin Export path Set classpath =.: $ java_home/lib/dt. jar: $ java_home/lib/tools. Jar Export classpath |
7. Now, JDK installation on Linux is complete.
#*************************#
Other methods for setting environment variables seen on the Internet have not been tested yet:
2. Set environment variables.
# Vi/etc/profile
Add at the end
# Set Java environment
Java_home =/usr/Java/jdk-1_5_0_02
Classpath =.: $ java_home/lib. Tools. Jar
Path = $ java_home/bin: $ path
Export java_home classpath path
Save and exit.
To enable JDK to be used by all users, you can:
VI/etc/profile. d/Java. Sh
Enter the following content in the new java. Sh file:
# Set Java environment
Java_home =/usr/Java/jdk-1_5_0_02
Classpath =.: $ java_home/lib/tools. Jar
Path = $ java_home/bin: $ path
Export java_home classpath path
Save and exit, and then assign the permission to Java. sh: chmod 755/etc/profile. d/Java. Sh
#---------------------------------------------------------------#
Summary:
The above basically shows the installation method on the Internet, but it is a little different when I install myself. I just took a few steps to install it.
There are not so many steps as above:
1. Go to the http://java.sun.com/j2se/1.4.2/download.html to download a Linux platform JDK, it is recommended to download RPM self-extract format (rpm in self-extracting file, j2sdk-1_4_2_06-linux-i586-rpm.bin );
2. Upload the file to a Linux server and run the following command in shell:
[Root @ linuxserver RPM] # chmod A + x jdk-6u10-linux-i586-rpm.bin [Root @ linuxserver RPM] #./jdk-6u10-linux-i586-rpm.bin |
There will be a piece of Sun Protocol, several times the Space key, when asked whether to agree, you can press Yes.
Sun Microsystems, Inc. Binary Code License Agreement For Javatm 2 software development kit (j2sdk), Standard Edition, version 1.4.2 _ x ... Do you agree to the above license terms? [Yes or No] Yes Unpacking... Checksumming... 0 0 Extracting... Unzipsfx 5.40 of 28 November 1998, by Info-zip (Zip-Bugs@lists.wku.edu ). Inflating: j2sdk-1_4_2_06-linux-i586.rpm Done. |
3. The program will automatically generate a j2sdk-1_4_2_06-linux-i586.rpm file, which is the main package, to install below;
[Root @ linuxserver RPM] # rpm-IVH jdk-6u10-linux-i586-rpm Preparing... ######################################## ### [100%] 1: j2sdk ####################################### #### [100%] |
After the installation is complete, both javac and Java will show the usage method, which indicates that the installation is successful. The difference between the two installation methods is that
The environment variable is installed with JDK, and I do not know what is going on. Is it because of the jdk1.6 update, the environment variable will be automatically set.
Fedora8 Version)