Installing JDK under Red Hat Linux

Source: Internet
Author: User
Tags echo command

1, download the Linux platform jdk download corresponding operating system JDK, the operating system is 32 bits of the next 32 bits of the jdk,64 bit of the next 64-bit JDK. I can't put it on the wrong page. : http://www. oracle.com/technetwork/java/javase/downloads/index.html https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/ cds-cds_developer-site/en_us/-/usd/[email protected]_developer

32-bit JDK specific: Jdk-6u23-linux-i586-rpm.bin http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en _us/-/usd/verifyitem-start/jdk-6u23-linux-i586-rpm.bin? Bundledlineitemuuid=rl6j_hcwjd8aaaet97cahgob&orderid=khsj_hcwr2saaaet5rcahgob&productid=qhoj_ Hcw.duaaaesfimckluk&filename=/jdk-6u23-linux-i586-rpm.bin 64-bit JDK specific: jdk-6u23-linux-x64-rpm.bin/HTTP cds.sun.com/is-bin/intershop.enfinity/wfs/cds-cds_developer-site/en_us/-/usd/verifyitem-start/ Jdk-6u23-linux-x64-rpm.bin? Bundledlineitemuuid=cg2j_hcwdbyaaaetfueahgog&orderid=_0.j_hcw1heaaaetceeahgog&productid=6ggj_ Hcwiqyaaaeskimckluk&filename=/jdk-6u23-linux-x64-rpm.bin

Select the platform:32 bit selection linux,64 bit of the Linux x64. Select the consent agreement and click the Continue button. It is recommended to download the RPM self-extracting format, download Jdk-6u23-linux-i586-rpm.bin here.

Create a folder named JDK under the Usr/local directory.

Create folder jdk [[email protected] ~] #mkdir/usr/local/jdk

Delete folder jdk [[email protected] ~] #rm-rf/usr/local/jdk

After downloading, copy the Jdk-6u23-linux-i586-rpm.bin file to the USR/LOCAL/JDK directory.

2. Uninstall Linux's own JDK

Log in to the system as root. Before installing the JDK, check with java-version to see if the JDK is already installed on the current Linux system, and jdk1.4 is installed by default in RedHat5.4 Enterprise Edition.

If so, please delete

[Email protected] ~]#yum remove Java

3. Install JDK with cd command to enter/USR/LOCAL/JDK directory: # CD/USR/LOCAL/JDK

Add executable permissions to all users: # chmod +x jdk-6u23-linux-i586-rpm.bin

Execute file: #./Jdk-1_5_0-linux-i586-rpm.bin

There will be an agreement that requires pressing the OK key .

The main package Jdk-6u23-linux-i586-rpm.bin and some other packages are generated, and the executable permissions are added to all users.

Install the main package jdk-6u23-linux-i586.rpm.

# RPM–IVH jdk-6u23-linux-i586.rpm

After the installation is complete, you can see the JDK in/usr/java.

4, set the JDK environment variable by changing the/etc/profile to implement, the command is: #sudo gedit/etc/profile

At the end of the open profile file, add the following code: JDK1.6.0_23 is the installed JDK file name, the version is different, and the file name is different. export java_home=/usr/java/jdk1.6.0_23 export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar Export path= $JAVA _home/bin: $PATH

Save the file and close profile.

5. Verify the JDK environment configuration reopen a terminal shell or restart your computer, enter the command to view the JDK version: # java–version

Use the echo command to check the configuration of the JDK environment variables. "It doesn't matter if you can't see the results" # echo $java_home # echo $classpath # echo $path

Create a file Test.java, write a Hello World test: #vi Test.java

The window appears, pressing the OK key.

Write code in VI Editor: class Test {public static void main (string[] args) {System.out.println ("Hello world!"); } }

After writing, press ESC , stop editing, and then press the colon key ":", enter ": Wq" At the end of the line, or stop editing, toggle the IME to uppercase, press two times in a row Z the letter key.

Back to Terminal shell window, enter command: # javac Test.java # java Test

6. Problems that may occur during installation cannot execute binary file hint information. 1), no permissions, switch users to root. 2), no file authorization, Authorization: # chmod +x jdk-6u23-linux-i586-rpm.bin //Add executable permissions to all users or # chmod 755 jdk-6u23-linux- I586-rpm.bin //Change file permissions to 755 3), installed JDK version incompatible, install the corresponding operating system JDK, operating system is 32-bit installed 32-bit jdk,64 bit of installation 64-bit JDK.

Installing JDK under Red Hat 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.