Install JDK and configure environment variables in Ubuntu

Source: Internet
Author: User
I used to worship those Linuxer Titans before. Recently, I have gradually turned to Ubuntu. in the true sense, I used dual systems (Win7 + Ubuntu) and gradually understood their enthusiasm for Linux. You have installed many tools and software using the command line and UbuntuSoftwareCenter, and the experience is really good. At least, Ubuntu's switch speed and no kill software are pretty cool. Currently, JDK is required for learning. I think it would be convenient to install all the required tools on Ubuntu.

I used to worship those Linuxer Titans before. Recently, I have gradually turned to Ubuntu. in the true sense, I used dual systems (Win7 + Ubuntu) and gradually understood their enthusiasm for Linux. Many tools and Software have been installed using the command line and Ubuntu Software Center, and the experience is really good. At least, Ubuntu's switch speed and no kill software are pretty cool. Currently, JDK is required for learning. I think, if you can install all the required tools on Ubuntu, which is convenient and skillful, it is estimated that Win7 will be able to stay cool.

JDK official: http://www.Oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Select the appropriate software package for download according to the system,

The difference between rpm1_tar.gz is simply explained. Rpm-format software packages are suitable for Red Hat-based systems, such as Red Hat Linux, SUSE, and Fedora. similarly, a software package in deb format is applicable to Debian-based systems, such as Debian, Ubuntu, and Mint. the tar.gz format is only a compressed package, which is generally the source code. Therefore, you only need to use the tar command or extract the software to decompress it to the corresponding path. I am using Ubuntu amd64. I chose jdk-7u11-linux-x64.tar.gz. After downloading it, I decompress it to the/usr/lib/java/directory (root permission is required ).

JDK environment variables are configured as follows:

Run the sudo gedit/etc/environment command to create two variables in the PATH variable in the open editor,

JAVA_HOME = "/usr/lib/java/jdk1.7.0 _ 11"

CLASSPATH = ".: $ JAVA_HOME/lib/tools. jar: $ JAVA_HOME/lib/dt. jar"

Add $ JAVA_HOME/bin in PATH. Note that the original values of PATH are separated by a colon (:). Do not delete the original values.

Then save and close the file. Run the source/etc/envrionment command to update the file.

By default, OpenJDK (usr/lib/jvm/) is installed and used in Ubuntu. Therefore, you must manually modify the default JDK of the system,

Sudo update-alternatives -- install/usr/bin/javac/usr/lib/java/jdk1.7.0 _ 11/bin/javac 300

Sudo update-alternatives -- install/usr/bin/java/usr/lib/java/jdk1.7.0 _ 11/bin/java 300

Sudo update-alternatives -- config javac, and then select the corresponding Priority 300

Sudo update-alternatives -- config java, and then select the corresponding Priority 300

Now the configuration is complete. Enter java-version, javac, or java to check whether the configuration is successful.

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.