Install JDK and set Java environment variables in Linux

Source: Internet
Author: User
Install JDK and set Java environment variables in Linux
1. download the latest j2sdk for Linux from www.sun.com.
2. Install jdk1.4.2 for Linux. The following example uses RedHat Linux 9:
Log On As root
(1) Open a terminal
(2) enter the LS-l command to view the permissions of the Installation File.
(3) enter the command chmod A + x j2sdk-1_4_2_01-linux-i586-rpm.bin to add execution permissions to all users.
(4) install JDK
/J2sdk-1_4_2_01-linux-i586-rpm.bin
After this step is complete, a file for the j2sdk-1_4_2_01-linux-i586.rpm is generated
View Permissions
Ls-l
Grant execution permissions to j2sdk-1_4_2_01-linux-i586.rpm
Chmod + x j2sdk-1_4_2_01-linux-i586.rpm
Install j2sdk-1_4_2_01-linux-i586.rpm
Rpm-IVH j2sdk-1_4_2_01-linux-i586-rpm
When the authorization Protocol appears, press enter to accept
(5) use the default installation location. Under/usr/Java/,/usr/Java/j2sdk1.4.2 _ 01
3. Set Environment Variables
Use the VI editor to edit environment variables:
Enter commands in the terminal
VI/etc/profile. d/Java. Sh
In this way, all users can use
Enter the following content in the new java. Sh file:
# Set Java environment
Export J *** a_home =/usr/Java/j2sdk1.4.2 _ 01
Export classpath =.: $ J ***** a_home/lib: $ J ***** a_home/JRE/lib
Export Path = $ J ***** a_home/bin: $ J ***** a_home/JRE/bin: $ path
Save and exit
Path and classpath both specify the path list. The items in the list (that is, each path) are separated by separators. In Windows, the Delimiter is a semicolon (;), while in Linux, The Delimiter is a colon (:).
4. Assign permissions to Java. Sh
Enter the following command:
Chmod 755/etc/profile. d/Java. Sh
5. restart the computer
Enter the following command in the terminal to test whether JDK is successfully installed.
Java-version
If JVM information is displayed, the installation is successful.

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.