Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install JDK in CentOS

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

CentOS how to install JDK, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Method 1: extract the JDK package manually, and then set the environment variable

1. Create a java directory under the / usr/ directory

[root@localhost ~] # mkdir/usr/java [root@localhost ~] # cd / usr/java

two。 Download jdk and extract it

[root@localhost java] # curl-O http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz [root@localhost java] # tar-zxvf jdk-7u79-linux-x64.tar.gz

3. Set environment variabl

[root@localhost java] # vi / etc/profile

Add the following to profile:

# set java environment JAVA_HOME=/usr/java/jdk1.7.0_79 JRE_HOME=/usr/java/jdk1.7.0_79/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH

Let the changes take effect:

[root@localhost java] # source / etc/profile

4. Verify the validity of JDK

[root@localhost java] # java-version java version "1.7.0,79" Java (TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot (TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

Method 2: install JDK with yum

1. Check which jdk versions are available in the yum library (only openjdk has been found for the time being)

[root@localhost ~] # yum search java | grep jdk ldapjdk-javadoc.x86_64: Javadoc for ldapjdk java-1.6.0-openjdk.x86_64: OpenJDK Runtime Environment java-1.6.0-openjdk-demo.x86_64: OpenJDK Demos java-1.6.0-openjdk-devel.x86_64: OpenJDK Development Environment java-1.6.0-openjdk-javadoc.x86_64: OpenJDK API Documentation java-1.6.0-openjdk-src.x86_64: OpenJDK Source Bundle java-1.7. 0-openjdk.x86_64: OpenJDK Runtime Environment java-1.7.0-openjdk-demo.x86_64: OpenJDK Demos java-1.7.0-openjdk-devel.x86_64: OpenJDK Development Environment java-1.7.0-openjdk-javadoc.noarch: OpenJDK API Documentation java-1.7.0-openjdk-src.x86_64: OpenJDK Source Bundle java-1.8.0-openjdk.x86_64: OpenJDK Runtime Environment java-1.8.0-openjdk-demo.x86_64: OpenJDK Demos java -1.8.0-openjdk-devel.x86_64: OpenJDK Development Environment java-1.8.0-openjdk-headless.x86_64: OpenJDK Runtime Environment java-1.8.0-openjdk-javadoc.noarch: OpenJDK API Documentation java-1.8.0-openjdk-src.x86_64: OpenJDK Source Bundle ldapjdk.x86_64: The Mozilla LDAP Java SDK

two。 Select a version to install

/ / Select version 1.7 to install [root@localhost ~] # yum install java-1.7.0-openjdk / / after installation, the default installation directory is at: / usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64

3. Set environment variabl

[root@localhost ~] # vi / etc/profile

Add the following to the profile file

# set java environment JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64 JRE_HOME=$JAVA_HOME/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH

Let the changes take effect

[root@localhost java] # source / etc/profile

4. Verification (same as the previous method)

Method 3: install JDK with rpm

1. Download the rpm installation file

[root@localhost ~] $curl-O http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm

two。 Install using the rpm command

[root@localhost ~] # rpm-ivh jdk-7u79-linux-x64.rpm

3. Set environment variabl

[root@localhost java] # vi / etc/profile

Add the following to the open profile file:

# set java environment JAVA_HOME=/usr/java/jdk1.7.0_79 JRE_HOME=/usr/java/jdk1.7.0_79/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH

Let the changes take effect

[root@localhost java] # source / etc/profile

4. Verification (same as the previous method)

Note: similar to the yum installation, you can run the java command without setting the environment variable. Rpm installation method installs jdk to / usr/java/jdk1.7.0_79 by default, and then links to / usr/bin through a three-tier link, as follows:

[root@localhost ~] # cd / bin [root@localhost bin] # ll | grep java lrwxrwxrwx. 1 root root 25 Mar 28 11:24 jar-> / usr/java/default/bin/jar lrwxrwxrwx. 1 root root 26 Mar 28 11:24 java-> / usr/java/default/bin/java lrwxrwxrwx. 1 root root 27 Mar 28 11:24 javac-> / usr/java/default/bin/javac lrwxrwxrwx. 1 root root 29 Mar 28 11:24 javadoc-> / usr/java/default/bin/javadoc lrwxrwxrwx. 1 root root 28 Mar 28 11:24 javaws-> / usr/java/default/bin/javaws lrwxrwxrwx. 1 root root 30 Mar 28 11:24 jcontrol-> / usr/java/default/bin/jcontrol [root@localhost bin] # cd / usr/java/ [root@localhost java] # ll total 4 lrwxrwxrwx. 1 root root 16 Mar 28 11:24 default- > / usr/java/latest drwxr-xr-x. 8 root root 4096 Mar 28 11:24 jdk1.7.0_79 lrwxrwxrwx. 1 root root 21 Mar 28 11:24 latest-> / usr/java/jdk1.7.0_79

Method 4: install JDK using apt-get on Ubuntu

1. Check what jdk versions are available in the apt library

Root@Itble:~# apt-cache search java | grep jdk default-jdk- Standard Java or Java compatible Development Kit default-jdk-doc-Standard Java or Java compatible Development Kit (documentation) gcj-4.6-jdk-gcj and classpath development tools for Java (TM) gcj-jdk-gcj and classpath development tools for Java (TM) openjdk-6-dbg-Java runtime based on OpenJDK (debugging symbols) openjdk-6-demo-Java runtime based on OpenJDK (demos and examples) openjdk-6-doc-OpenJDK Development Kit (JDK) documentation openjdk-6-jdk OpenJDK Development Kit (JDK) openjdk-6-jre-lib-OpenJDK Java runtime (architecture independent libraries) openjdk-6-source-OpenJDK Development Kit (JDK) source files openjdk-7-dbg-Java runtime based on OpenJDK (debugging symbols) openjdk-7-demo-Java runtime based on OpenJDK (demos and examples) openjdk-7-doc-OpenJDK Development Kit (JDK) documentation openjdk-7-jdk-OpenJDK Development Kit (JDK) openjdk-7-source-OpenJDK Development Kit (JDK) source files uwsgi-plugin-jvm-openjdk-6-Java plugin for UWSGI (OpenJDK 6) uwsgi-plugin-jwsgi-openjdk-6-JWSGI plugin for uWSGI (OpenJDK 6) openjdk-6-jre-OpenJDK Java runtime Using Hotspot JIT openjdk-6-jre-headless-OpenJDK Java runtime, using Hotspot JIT (headless) openjdk-7-jre- OpenJDK Java runtime, using Hotspot JIT openjdk-7-jre-headless-OpenJDK Java runtime, using Hotspot JIT (headless) openjdk-7-jre-lib-OpenJDK Java runtime (architecture independent libraries)

two。 Select a version to install

Root@Itble:~# apt-get install openjdk-7-jdk

3. Set environment variabl

Root@Itble:~# vi / etc/profile

Add the following to the open profile file

# set java environment JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64 JRE_HOME=$JAVA_HOME/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH

Let the changes take effect

Is it helpful for root@Itble:~# source / etc/profile to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report