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