Home php教程 PHP开发 Install JDK and configure environment variables on Linux

Install JDK and configure environment variables on Linux

Dec 17, 2016 pm 01:39 PM

JDK download address:

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

Install JDK and configure environment variables on Linux

Choose 64-bit or 32-bit download according to the version of Linux system , the official now provides rpm and tar.gz versions for download.


Installation:

[root@oracle cdrom]# rpm -ivh jdk-8u25-linux-x64.rpm


Configure jdk environment variables

Method 1: Set variables under Shell (this method Only valid for the current shell, if you open another shell, you need to reconfigure it)

export JAVA_HOME=/usr/java/jdk1.7.0_40/
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$ JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

(It is also OK if you only configure export PATH=/usr/java/jdk1.7.0_40/bin:$PATH)

Method 2: Modify the /etc/profile file (this method is once and for all, set once and is valid for all users)

Open the /etc/profile file with the vim editor and add the definition of environment variables at the end of the file

JAVA_HOME=/usr/java/jdk1 .8.0_25/

PATH=$JAVA_HOME/bin:$PATH

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH

Save Exit and check the java version

[root@oracle cdrom]# java -version

java version "1.8.0_25"

Java(TM) SE Runtime Environment (build 1.8.0_25-b17)

Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

means the installation is successful

Method 3: Modify the ~/.bashrc file (this method is only effective for the current user after modification, and all shells of this user will be affected) Valid)

Open the ~/.bashrc file with the vim editor

Add the definition of the jdk environment variable at the end of the file

set JAVA_HOME=/usr/java/jdk1.8.0_25/

export JAVA_HOME

set PATH=$ JAVA_HOME/bin:$PATH

export PATH

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

export CLASSPATH



More Linux installations For articles related to JDK and configuring environment variables, please pay attention to the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)