Install Java and Tomcat under Ubuntu

Source: Internet
Author: User
Tags linux mint

Ubuntu installs JDK in two ways: Install the JRE using ppa/source Mode 1

Open the terminal and install the JRE using the following command:

default-jre
2 Installing OPENJDK

On Ubuntu and Linux Mint on the installOpenJDK

At the terminal, install the OPENJDK Java SDK using the following command:

default-jdk

Specifically, if you want to install Java 8 , Java 7 or Java 6 so on, you can use openjdk-7-jdk/openjdk-6jdk , but remember to install it beforeopenjdk-7-jre/openjdk-6-jre

3 Installing the Oracle JDK

On Ubuntu and Linux Mint on the installOracle JDK

3.1 Using the source installation

Use the following command to install, just some time, it will download a lot of files, and you want to make sure that your network environment is good:

sudo add-apt-repository ppa:webupd8team/javasudo apt-get updatesudo apt-get install oracle-java8-installersudo apt-get install oracle-java8-set-default

If you want to install Java 8(i.e Java 1.8) it, replace it in the command above java7 java8 .

Installing through the bin package

You can also install the common Bin package on Linux, download the official bin package, install the decompression under the terminal, and then modify the environment variable to point to the JDK

Select a different version as needed to download the bin package

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Unzip the downloaded jdk-8u101-linux-x64.tar.gz file.

Use the following command to extract:

sudo tar zxvf ./jdk-8u101-linux-x64.tar.gz -C /usr/java/jdk1.8.0_101

To facilitate management, the extracted files can be moved to another folder, the author moved the file to the /usr/java/jdk1.8.0_101 directory.

To facilitate the next set of environment variables, change the folder to a shorter name-jdk1.8

MV Jdk1.8.0_101 jdk1.8

1 Setting environment variables

Edit. bashrc file

Vim ~/.BASHRC

JAVA_HOME=/usr/java/jdk1.8.0_101JRE_HOME=$JAVA_HOME/jreJAVA_BIN=$JAVA_HOME/binCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/libPATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/binexport JAVA_HOME JRE_HOME PATH CLASSPATH

If you installed using the source method, the default installation path is in /usr/lib/jvm/java-8-oracle , and the corresponding Java_home is configured

JAVA_HOME=/usr/lib/jvm/java-8-oracle

In order for the changes to take effect immediately, execute the following command at the terminal:

source ~/.bashrc

2 Verification

With the above steps, the JDK is installed.

Enter the following command java -version to verify that

Install Java and Tomcat under Ubuntu

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.