How to install JDK in Linux

Source: Internet
Author: User

Recently, you need to write Java in LinuxCodeCheck some methods for installing JDK. At last, the apt-Get method is relatively simple, but some problems have also been encountered. The method is as follows:

Environment: vmwarevm, ubuntu10.04 System

First, add the available URLs to the APT software resource list:

(1) Add URL: Deb http://ftp.hk.debian.org/debian squeeze main non-free in sources. List under/etc/Apt

Note: No available resources are found in the previous update with APT-Get update. Therefore, you must manually add the website address.

(2) Save and use the apt-Get update command to update

Note: if an error apt: cache-limit occurs during the update, you must use the apt in/etc/apt. conf (create a new file if the file does not exist) add apt: cache-limit 99999999; To increase the cache limit

Second, use the apt-Get install sun-java6-jdk to install JDK. ()

Note: I thought I had to set the environment variables after installation, but I didn't set the environment variables after installation, so I can correctly perform step 3 (set java_home when installing JDK in Windows, class_path, PATH ).

Third test:

(1) Use the javac-version command on the terminal to view the version information: (as follows)

Javac 1.6.0 _ 26
(2) Compile the test file: Test. Java

Public class test
{
Public static void main (string [] ARGs)
{
System. Out. println ("Hello world! ");
}
}

(3) compile and generate test. Class in javac-test. Java, and run it in Java test. Hello world! is displayed !. The installation is successful.

Note: The following is the URL used to add sources. list. You can check it in (for Ubuntu)

Http://packages.debian.org/squeeze/i386/sun-java6-jdk/download

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.