(go) Uninstall and install the JDK on Linux

Source: Internet
Author: User

Uninstall default: Log in to the system with the root user, open a terminal input # Rpm-qa|grep GCJ display content contains the following two lines of information # JAVA-1.4.2-GCJ-COMPAT-1.4.2.0-27JPP # JAVA-1.4.2-GCJ-COMPAT-DEVEL-L.4.2.0-27JPP Uninstall # rpm-e JAVA-1.4.2-GCJ-COMPAT-DEVEL-L.4.2.0-27JPP # RPM-E Java-1.4.2-gcj-compat-l.4.2.0-27jpp

Uninstall other JDK you have installed directly with rpm-e <javaXXXXX> uninstall RPM version of JDK:

#rpm-qa|grep JDK

Display: Jdk-1.6.0_10-fcs Uninstall: #rpm-e--nodeps Jdk-1.6.0_10-fcs

Installation: 1. Go to http://java.sun.com/j2se/1.4.2/download.html. 1.4.2 For example, to 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 Kits (J2SDK), Standard EDITION, VERS ION 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 likes 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. I use the following [[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 Span style= "color:red;" >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 settings are 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_0 6-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) {Sys        Tem.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 JAVA commands, [[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.

(go) Uninstall and install the JDK on Linux

Related Article

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.