Install JDK1.6 under Linux

Source: Internet
Author: User

long time No blog, and recently began to learn Java, a little learning Java experience, share:1. To http://java.sun.com/j2se/1.4.2/download.html download a Linux platform JDK, it is recommended to download the RPM self-extracting format (RPM in self-extracting File,j2sdk-1_4_2_06-linux-i586-rpm.bin);

2. Upload to a Linux server and execute commands under the shell:

[Email protected] rpm]# chmod 755 j2sdk-1_4_2_06-linux-i586-rpm.bin
[Email protected] rpm]#./j2sdk-1_4_2_06-linux-i586-rpm.bin

There will be a sun agreement, a few times the space bar, when asked whether or not to agree, knock Yes.
Sun Microsystems, Inc.
Binary Code License Agreement
For the
JAVATM 2 software Development KIT (J2SDK), standard
EDITION, VERSION 1.4.2_x
...
Agree to the above license terms? [Yes or No]yes
Unpacking ...
Checksumming ...
0
0
Extracting ...
UNZIPSFX 5.40 of November 1998, by Info-zip ([email protected]).
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, installed below;
[[email protected] rpm] #rpm –IVH j2sdk-1_4_2_06-linux-i586.rpm
Preparing ... ########################################### [100%]
1:J2SDK ########################################### [100%]

4. Setting Environment variables
Usually prefer to set directly under the shell with the Export command
[Email protected] rpm]# export java_home=/usr/java/j2sdk1.4.2_06
[Email protected] rpm]# export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
[Email protected] rpm]# export path= $PATH: $JAVA _home/bin
Of course, setting an environment variable can be effective, but only for the current shell. If you log in from another shell, you will not be able to use the variable you just set. So the best way is to modify the. bashrc file.
[[email protected] 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, this can be done by changing the/etc/profile, but it is not recommended because such a setting will affect the security of the system so that the user's shell is in effect. The following is to verify that the variable setting is in effect (logout before verification, then re-login);
[Email protected] rpm]# echo $JAVA _home
/usr/java/j2sdk1.4.2_06/
[Email protected] rpm]# echo $CLASSPATH
/usr/java/j2sdk1.4.2_06/lib/dt.jar:/usr/java/j2sdk1.4.2_06/lib/tools.jar
[Email protected] 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
[Email protected] 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. Environment settings OK, to see if the JDK works, let's write a test file Test.java
[[email protected] rpm] #vi Test.java
Class Test
{
public static void Main (string[] args)
{
System.out.println ("Hello world!");
}
}

Save exit, below to compile, execute;
[Email protected] text]# Javac Test.java
[[email protected] text]# JAVA test
Hello world!

OK, it works fine.
6. If you want a user to have permission to run Java commands, simply modify their bash initialization file.
For example, to give the user Longware to run the Java command,
[Email protected] 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. This completes the installation of the JDK on Linux.

#*************************#
Other ways to set environment variables on the web are not yet measured:
2. Set environment variables.
#vi/etc/profile
On the last side, add
#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 exit.

To make the JDK available to all users, you can:
vi/etc/profile.d/java.sh
In the new java.sh, enter the following:
#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 exit and assign permissions to java.sh: chmod 755/etc/profile.d/java.sh

#---------------------------------------------------------------#
Self-Summary:
The above is basically to see the installation method on the Internet, but the installation of the time but a little out of the way, I installed a few steps to be able to
It doesn't take as many steps as it did above:

1. To http://java.sun.com/j2se/1.4.2/download.html download a Linux platform JDK, it is recommended to download the RPM self-extracting format (rpm in Self-Extracting file,j2sdk-1_4_2_06-linux-i586-rpm.bin);
2. Upload to a Linux server and execute commands under the shell:
[Email protected] rpm]# chmod a+x jdk-6u10-linux-i586-rpm.bin
[Email protected] rpm]#./jdk-6u10-linux-i586-rpm.bin

There will be a sun agreement, a few times the space bar, when asked whether or not to agree, knock Yes.
Sun Microsystems, Inc.
Binary Code License Agreement
For the
JAVATM 2 software Development KIT (J2SDK), standard
EDITION, VERSION 1.4.2_x
...
Agree to the above license terms? [Yes or No]yes
Unpacking ...
Checksumming ...
0
0
Extracting ...
UNZIPSFX 5.40 of November 1998, by Info-zip ([email protected]).
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, installed below;
[[email protected] rpm] #rpm –IVH jdk-6u10-linux-i586-rpm
Preparing ... ########################################### [100%]
1:J2SDK ########################################### [100%]

After installation, the use method is displayed directly with Javac and Java, so the installation is successful. The difference between the above two installation methods is that there is no setting
Environment variables on the installation of the JDK, I do not know what the matter, is it JDK1.6 update for the sake of automatically set environment variables. (I Linux
Version is Fedora8)

Install JDK1.6 under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.