CentOS JAVA安装及查看路径方法
CentOS JAVA安装及查看路径方法
2017-06-02 21:24
一、安装:
方法一:手动解压JDK的压缩包,然后设置环境变量
1.在/usr/目录下创建java目录
[root@localhost ~]# mkdir/usr/java
[root@localhost ~]# cd /usr/java
2.下载jdk,然后解压
[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.设置环境变量
[root@localhost java]# vi /etc/profile
在profile中添加如下内容:
#set java environment
JAVA_HOME=/usr/java/jdk1.7.0_79
JRE_HOME=/usr/java/jdk1.7.0_79/jre
CLASS_PATH=.:<span style="display: inline-block; position: relative; width: 11.52em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(2.077em, 1011.44em, 3.397em, -1000em); top: -2.987em; left: 0em;"><span id="MathJax-Span-2" class="mrow"><span id="MathJax-Span-3" class="mi" style="font-family: MathJax_Math; font-style: italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.078em;"><span id="MathJax-Span-4" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-5" class="mi" style="font-family: MathJax_Math; font-style: italic; text-rendering: optimizelegibility;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.186em;"><span id="MathJax-Span-6" class="msubsup"><span style="display: inline-block; position: relative; width: 1.453em; height: 0px;"><span style="position: absolute; clip: rect(3.124em, 1000.73em, 4.16em, -1000em); top: -4em; left: 0em;"><span id="MathJax-Span-7" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span style="display: inline-block; width: 0px; height: 4em;"><span style="position: absolute; top: -3.85em; left: 0.75em;"><span id="MathJax-Span-8" class="mi" style="font-size: 70.7%; font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.04em;"><span style="display: inline-block; width: 0px; height: 4em;"><span id="MathJax-Span-9" class="mi" style="font-family: MathJax_Math; font-style: italic;">O<span id="MathJax-Span-10" class="mi" style="font-family: MathJax_Math; font-style: italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.081em;"><span id="MathJax-Span-11" class="mi" style="font-family: MathJax_Math; font-style: italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.026em;"><span id="MathJax-Span-12" class="texatom"><span id="MathJax-Span-13" class="mrow"><span id="MathJax-Span-14" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-15" class="mi" style="font-family: MathJax_Math; font-style: italic;">l<span id="MathJax-Span-16" class="mi" style="font-family: MathJax_Math; font-style: italic;">i<span id="MathJax-Span-17" class="mi" style="font-family: MathJax_Math; font-style: italic;">b<span id="MathJax-Span-18" class="texatom"><span id="MathJax-Span-19" class="mrow"><span id="MathJax-Span-20" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-21" class="mi" style="font-family: MathJax_Math; font-style: italic;">d<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"><span id="MathJax-Span-22" class="mi" style="font-family: MathJax_Math; font-style: italic;">t<span id="MathJax-Span-23" class="mo" style="font-family: MathJax_Main;">.<span id="MathJax-Span-24" class="mi" style="font-family: MathJax_Math; font-style: italic; padding-left: 0.167em;">j<span id="MathJax-Span-25" class="mi" style="font-family: MathJax_Math; font-style: italic;">a<span id="MathJax-Span-26" class="mi" style="font-family: MathJax_Math; font-style: italic;">r<span id="MathJax-Span-27" class="mo" style="font-family: MathJax_Main; padding-left: 0.278em;">:
JAVA_HOME/lib/tools.jar:<span style="display: inline-block; position: relative; width: 11.147em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(2.077em, 1011.09em, 3.397em, -1000em); top: -2.987em; left: 0em;"><span id="MathJax-Span-29" class="mrow"><span id="MathJax-Span-30" class="mi" style="font-family: MathJax_Math; font-style: italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.078em;"><span id="MathJax-Span-31" class="mi" style="font-family: MathJax_Math; font-style: italic;">R<span id="MathJax-Span-32" class="msubsup"><span style="display: inline-block; position: relative; width: 1.441em; height: 0px;"><span style="position: absolute; clip: rect(3.16em, 1000.76em, 4.16em, -1000em); top: -4em; left: 0em;"><span id="MathJax-Span-33" class="mi" style="font-family: MathJax_Math; font-style: italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.026em;"><span style="display: inline-block; width: 0px; height: 4em;"><span style="position: absolute; top: -3.85em; left: 0.738em;"><span id="MathJax-Span-34" class="mi" style="font-size: 70.7%; font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.04em;"><span style="display: inline-block; width: 0px; height: 4em;"><span id="MathJax-Span-35" class="mi" style="font-family: MathJax_Math; font-style: italic;">O<span id="MathJax-Span-36" class="mi" style="font-family: MathJax_Math; font-style: italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.081em;"><span id="MathJax-Span-37" class="mi" style="font-family: MathJax_Math; font-style: italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.026em;"><span id="MathJax-Span-38" class="texatom"><span id="MathJax-Span-39" class="mrow"><span id="MathJax-Span-40" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-41" class="mi" style="font-family: MathJax_Math; font-style: italic;">l<span id="MathJax-Span-42" class="mi" style="font-family: MathJax_Math; font-style: italic;">i<span id="MathJax-Span-43" class="mi" style="font-family: MathJax_Math; font-style: italic;">b<span id="MathJax-Span-44" class="mi" style="font-family: MathJax_Math; font-style: italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"><span id="MathJax-Span-45" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-46" class="mi" style="font-family: MathJax_Math; font-style: italic;">T<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.12em;"><span id="MathJax-Span-47" class="mi" style="font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.057em;"><span id="MathJax-Span-48" class="mo" style="font-family: MathJax_Main; padding-left: 0.278em;">=PATH:<span style="display: inline-block; position: relative; width: 8.64em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(2.077em, 1008.56em, 3.397em, -1000em); top: -2.987em; left: 0em;"><span id="MathJax-Span-50" class="mrow"><span id="MathJax-Span-51" class="mi" style="font-family: MathJax_Math; font-style: italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.078em;"><span id="MathJax-Span-52" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-53" class="mi" style="font-family: MathJax_Math; font-style: italic; text-rendering: optimizelegibility;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.186em;"><span id="MathJax-Span-54" class="msubsup"><span style="display: inline-block; position: relative; width: 1.453em; height: 0px;"><span style="position: absolute; clip: rect(3.124em, 1000.73em, 4.16em, -1000em); top: -4em; left: 0em;"><span id="MathJax-Span-55" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span style="display: inline-block; width: 0px; height: 4em;"><span style="position: absolute; top: -3.85em; left: 0.75em;"><span id="MathJax-Span-56" class="mi" style="font-size: 70.7%; font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.04em;"><span style="display: inline-block; width: 0px; height: 4em;"><span id="MathJax-Span-57" class="mi" style="font-family: MathJax_Math; font-style: italic;">O<span id="MathJax-Span-58" class="mi" style="font-family: MathJax_Math; font-style: italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.081em;"><span id="MathJax-Span-59" class="mi" style="font-family: MathJax_Math; font-style: italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.026em;"><span id="MathJax-Span-60" class="texatom"><span id="MathJax-Span-61" class="mrow"><span id="MathJax-Span-62" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-63" class="mi" style="font-family: MathJax_Math; font-style: italic;">b<span id="MathJax-Span-64" class="mi" style="font-family: MathJax_Math; font-style: italic;">i<span id="MathJax-Span-65" class="mi" style="font-family: MathJax_Math; font-style: italic;">n<span id="MathJax-Span-66" class="mo" style="font-family: MathJax_Main; padding-left: 0.278em;">:
JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效:
[root@localhost java]# source /etc/profile
4.验证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)
方法二:用yum安装JDK
1.查看yum库中都有哪些jdk版本(暂时只发现了openjdk)
[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
2.选择版本,进行安装
//选择1.7版本进行安装
[root@localhost ~]# yum install java-1.7.0-openjdk
//安装完之后,默认的安装目录是在: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64
3.设置环境变量
[root@localhost ~]# vi /etc/profile
在profile文件中添加如下内容
#set java environment
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64
JRE_HOME=<span style="display: inline-block; position: relative; width: 16.213em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(2.077em, 1016.13em, 3.397em, -1000em); top: -2.987em; left: 0em;"><span id="MathJax-Span-68" class="mrow"><span id="MathJax-Span-69" class="mi" style="font-family: MathJax_Math; font-style: italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.078em;"><span id="MathJax-Span-70" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-71" class="mi" style="font-family: MathJax_Math; font-style: italic; text-rendering: optimizelegibility;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.186em;"><span id="MathJax-Span-72" class="msubsup"><span style="display: inline-block; position: relative; width: 1.453em; height: 0px;"><span style="position: absolute; clip: rect(3.124em, 1000.73em, 4.16em, -1000em); top: -4em; left: 0em;"><span id="MathJax-Span-73" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span style="display: inline-block; width: 0px; height: 4em;"><span style="position: absolute; top: -3.85em; left: 0.75em;"><span id="MathJax-Span-74" class="mi" style="font-size: 70.7%; font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.04em;"><span style="display: inline-block; width: 0px; height: 4em;"><span id="MathJax-Span-75" class="mi" style="font-family: MathJax_Math; font-style: italic;">O<span id="MathJax-Span-76" class="mi" style="font-family: MathJax_Math; font-style: italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.081em;"><span id="MathJax-Span-77" class="mi" style="font-family: MathJax_Math; font-style: italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.026em;"><span id="MathJax-Span-78" class="texatom"><span id="MathJax-Span-79" class="mrow"><span id="MathJax-Span-80" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-81" class="mi" style="font-family: MathJax_Math; font-style: italic;">j<span id="MathJax-Span-82" class="mi" style="font-family: MathJax_Math; font-style: italic;">r<span id="MathJax-Span-83" class="mi" style="font-family: MathJax_Math; font-style: italic;">e<span id="MathJax-Span-84" class="mi" style="font-family: MathJax_Math; font-style: italic;">C<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.045em;"><span id="MathJax-Span-85" class="mi" style="font-family: MathJax_Math; font-style: italic;">L<span id="MathJax-Span-86" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-87" class="mi" style="font-family: MathJax_Math; font-style: italic;">S<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.032em;"><span id="MathJax-Span-88" class="msubsup"><span style="display: inline-block; position: relative; width: 1.219em; height: 0px;"><span style="position: absolute; clip: rect(3.135em, 1000.65em, 4.182em, -1000em); top: -4em; left: 0em;"><span id="MathJax-Span-89" class="mi" style="font-family: MathJax_Math; font-style: italic;">S<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.032em;"><span style="display: inline-block; width: 0px; height: 4em;"><span style="position: absolute; top: -3.85em; left: 0.613em;"><span id="MathJax-Span-90" class="mi" style="font-size: 70.7%; font-family: MathJax_Math; font-style: italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.077em;"><span style="display: inline-block; width: 0px; height: 4em;"><span id="MathJax-Span-91" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-92" class="mi" style="font-family: MathJax_Math; font-style: italic;">T<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.12em;"><span id="MathJax-Span-93" class="mi" style="font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.057em;"><span id="MathJax-Span-94" class="mo" style="font-family: MathJax_Main; padding-left: 0.278em;">=<span id="MathJax-Span-95" class="mo" style="font-family: MathJax_Main;">.<span id="MathJax-Span-96" class="mo" style="font-family: MathJax_Main; padding-left: 0.167em;">:
JAVA_HOME/lib/dt.jar:<span style="display: inline-block; position: relative; width: 12.747em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(2.077em, 1012.67em, 3.397em, -1000em); top: -2.987em; left: 0em;"><span id="MathJax-Span-98" class="mrow"><span id="MathJax-Span-99" class="mi" style="font-family: MathJax_Math; font-style: italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.078em;"><span id="MathJax-Span-100" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-101" class="mi" style="font-family: MathJax_Math; font-style: italic; text-rendering: optimizelegibility;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.186em;"><span id="MathJax-Span-102" class="msubsup"><span style="display: inline-block; position: relative; width: 1.453em; height: 0px;"><span style="position: absolute; clip: rect(3.124em, 1000.73em, 4.16em, -1000em); top: -4em; left: 0em;"><span id="MathJax-Span-103" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span style="display: inline-block; width: 0px; height: 4em;"><span style="position: absolute; top: -3.85em; left: 0.75em;"><span id="MathJax-Span-104" class="mi" style="font-size: 70.7%; font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.04em;"><span style="display: inline-block; width: 0px; height: 4em;"><span id="MathJax-Span-105" class="mi" style="font-family: MathJax_Math; font-style: italic;">O<span id="MathJax-Span-106" class="mi" style="font-family: MathJax_Math; font-style: italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.081em;"><span id="MathJax-Span-107" class="mi" style="font-family: MathJax_Math; font-style: italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.026em;"><span id="MathJax-Span-108" class="texatom"><span id="MathJax-Span-109" class="mrow"><span id="MathJax-Span-110" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-111" class="mi" style="font-family: MathJax_Math; font-style: italic;">l<span id="MathJax-Span-112" class="mi" style="font-family: MathJax_Math; font-style: italic;">i<span id="MathJax-Span-113" class="mi" style="font-family: MathJax_Math; font-style: italic;">b<span id="MathJax-Span-114" class="texatom"><span id="MathJax-Span-115" class="mrow"><span id="MathJax-Span-116" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-117" class="mi" style="font-family: MathJax_Math; font-style: italic;">t<span id="MathJax-Span-118" class="mi" style="font-family: MathJax_Math; font-style: italic;">o<span id="MathJax-Span-119" class="mi" style="font-family: MathJax_Math; font-style: italic;">o<span id="MathJax-Span-120" class="mi" style="font-family: MathJax_Math; font-style: italic;">l<span id="MathJax-Span-121" class="mi" style="font-family: MathJax_Math; font-style: italic;">s<span id="MathJax-Span-122" class="mo" style="font-family: MathJax_Main;">.<span id="MathJax-Span-123" class="mi" style="font-family: MathJax_Math; font-style: italic; padding-left: 0.167em;">j<span id="MathJax-Span-124" class="mi" style="font-family: MathJax_Math; font-style: italic;">a<span id="MathJax-Span-125" class="mi" style="font-family: MathJax_Math; font-style: italic;">r<span id="MathJax-Span-126" class="mo" style="font-family: MathJax_Main; padding-left: 0.278em;">:JRE_HOME/lib
PATH=<span style="display: inline-block; position: relative; width: 3.627em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(2.111em, 1003.55em, 3.147em, -1000em); top: -2.987em; left: 0em;"><span id="MathJax-Span-128" class="mrow"><span id="MathJax-Span-129" class="mi" style="font-family: MathJax_Math; font-style: italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"><span id="MathJax-Span-130" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-131" class="mi" style="font-family: MathJax_Math; font-style: italic;">T<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.12em;"><span id="MathJax-Span-132" class="mi" style="font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.057em;"><span id="MathJax-Span-133" class="mo" style="font-family: MathJax_Main; padding-left: 0.278em;">:
JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效
[root@localhost java]# source /etc/profile
4.验证(同上一方法)
方法三:用rpm安装JDK
1.下载rpm安装文件
[root@localhost ~]$ curl -O http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm
2.使用rpm命令安装
[root@localhost ~]# rpm -ivh jdk-7u79-linux-x64.rpm
3.设置环境变量
[root@localhost java]# vi /etc/profile
在打开的profile文件中添加如下内容
#set java environment
JAVA_HOME=/usr/java/jdk1.7.0_79
JRE_HOME=/usr/java/jdk1.7.0_79/jre
CLASS_PATH=.:<span style="display: inline-block; position: relative; width: 11.52em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(2.077em, 1011.44em, 3.397em, -1000em); top: -2.987em; left: 0em;"><span id="MathJax-Span-135" class="mrow"><span id="MathJax-Span-136" class="mi" style="font-family: MathJax_Math; font-style: italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.078em;"><span id="MathJax-Span-137" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-138" class="mi" style="font-family: MathJax_Math; font-style: italic; text-rendering: optimizelegibility;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.186em;"><span id="MathJax-Span-139" class="msubsup"><span style="display: inline-block; position: relative; width: 1.453em; height: 0px;"><span style="position: absolute; clip: rect(3.124em, 1000.73em, 4.16em, -1000em); top: -4em; left: 0em;"><span id="MathJax-Span-140" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span style="display: inline-block; width: 0px; height: 4em;"><span style="position: absolute; top: -3.85em; left: 0.75em;"><span id="MathJax-Span-141" class="mi" style="font-size: 70.7%; font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.04em;"><span style="display: inline-block; width: 0px; height: 4em;"><span id="MathJax-Span-142" class="mi" style="font-family: MathJax_Math; font-style: italic;">O<span id="MathJax-Span-143" class="mi" style="font-family: MathJax_Math; font-style: italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.081em;"><span id="MathJax-Span-144" class="mi" style="font-family: MathJax_Math; font-style: italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.026em;"><span id="MathJax-Span-145" class="texatom"><span id="MathJax-Span-146" class="mrow"><span id="MathJax-Span-147" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-148" class="mi" style="font-family: MathJax_Math; font-style: italic;">l<span id="MathJax-Span-149" class="mi" style="font-family: MathJax_Math; font-style: italic;">i<span id="MathJax-Span-150" class="mi" style="font-family: MathJax_Math; font-style: italic;">b<span id="MathJax-Span-151" class="texatom"><span id="MathJax-Span-152" class="mrow"><span id="MathJax-Span-153" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-154" class="mi" style="font-family: MathJax_Math; font-style: italic;">d<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"><span id="MathJax-Span-155" class="mi" style="font-family: MathJax_Math; font-style: italic;">t<span id="MathJax-Span-156" class="mo" style="font-family: MathJax_Main;">.<span id="MathJax-Span-157" class="mi" style="font-family: MathJax_Math; font-style: italic; padding-left: 0.167em;">j<span id="MathJax-Span-158" class="mi" style="font-family: MathJax_Math; font-style: italic;">a<span id="MathJax-Span-159" class="mi" style="font-family: MathJax_Math; font-style: italic;">r<span id="MathJax-Span-160" class="mo" style="font-family: MathJax_Main; padding-left: 0.278em;">:
JAVA_HOME/lib/tools.jar:<span style="display: inline-block; position: relative; width: 11.147em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(2.077em, 1011.09em, 3.397em, -1000em); top: -2.987em; left: 0em;"><span id="MathJax-Span-162" class="mrow"><span id="MathJax-Span-163" class="mi" style="font-family: MathJax_Math; font-style: italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.078em;"><span id="MathJax-Span-164" class="mi" style="font-family: MathJax_Math; font-style: italic;">R<span id="MathJax-Span-165" class="msubsup"><span style="display: inline-block; position: relative; width: 1.441em; height: 0px;"><span style="position: absolute; clip: rect(3.16em, 1000.76em, 4.16em, -1000em); top: -4em; left: 0em;"><span id="MathJax-Span-166" class="mi" style="font-family: MathJax_Math; font-style: italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.026em;"><span style="display: inline-block; width: 0px; height: 4em;"><span style="position: absolute; top: -3.85em; left: 0.738em;"><span id="MathJax-Span-167" class="mi" style="font-size: 70.7%; font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.04em;"><span style="display: inline-block; width: 0px; height: 4em;"><span id="MathJax-Span-168" class="mi" style="font-family: MathJax_Math; font-style: italic;">O<span id="MathJax-Span-169" class="mi" style="font-family: MathJax_Math; font-style: italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.081em;"><span id="MathJax-Span-170" class="mi" style="font-family: MathJax_Math; font-style: italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.026em;"><span id="MathJax-Span-171" class="texatom"><span id="MathJax-Span-172" class="mrow"><span id="MathJax-Span-173" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-174" class="mi" style="font-family: MathJax_Math; font-style: italic;">l<span id="MathJax-Span-175" class="mi" style="font-family: MathJax_Math; font-style: italic;">i<span id="MathJax-Span-176" class="mi" style="font-family: MathJax_Math; font-style: italic;">b<span id="MathJax-Span-177" class="mi" style="font-family: MathJax_Math; font-style: italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"><span id="MathJax-Span-178" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-179" class="mi" style="font-family: MathJax_Math; font-style: italic;">T<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.12em;"><span id="MathJax-Span-180" class="mi" style="font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.057em;"><span id="MathJax-Span-181" class="mo" style="font-family: MathJax_Main; padding-left: 0.278em;">=PATH:<span style="display: inline-block; position: relative; width: 8.64em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(2.077em, 1008.56em, 3.397em, -1000em); top: -2.987em; left: 0em;"><span id="MathJax-Span-183" class="mrow"><span id="MathJax-Span-184" class="mi" style="font-family: MathJax_Math; font-style: italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.078em;"><span id="MathJax-Span-185" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-186" class="mi" style="font-family: MathJax_Math; font-style: italic; text-rendering: optimizelegibility;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.186em;"><span id="MathJax-Span-187" class="msubsup"><span style="display: inline-block; position: relative; width: 1.453em; height: 0px;"><span style="position: absolute; clip: rect(3.124em, 1000.73em, 4.16em, -1000em); top: -4em; left: 0em;"><span id="MathJax-Span-188" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span style="display: inline-block; width: 0px; height: 4em;"><span style="position: absolute; top: -3.85em; left: 0.75em;"><span id="MathJax-Span-189" class="mi" style="font-size: 70.7%; font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.04em;"><span style="display: inline-block; width: 0px; height: 4em;"><span id="MathJax-Span-190" class="mi" style="font-family: MathJax_Math; font-style: italic;">O<span id="MathJax-Span-191" class="mi" style="font-family: MathJax_Math; font-style: italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.081em;"><span id="MathJax-Span-192" class="mi" style="font-family: MathJax_Math; font-style: italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.026em;"><span id="MathJax-Span-193" class="texatom"><span id="MathJax-Span-194" class="mrow"><span id="MathJax-Span-195" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-196" class="mi" style="font-family: MathJax_Math; font-style: italic;">b<span id="MathJax-Span-197" class="mi" style="font-family: MathJax_Math; font-style: italic;">i<span id="MathJax-Span-198" class="mi" style="font-family: MathJax_Math; font-style: italic;">n<span id="MathJax-Span-199" class="mo" style="font-family: MathJax_Main; padding-left: 0.278em;">:
JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效
[root@localhost java]# source /etc/profile
4.验证(同上一方法)
注:和yum安装类似,不用设置环境变量就可以运行java命令。rpm安装方式默认会把jdk安装到/usr/java/jdk1.7.0_79,然后通过三层链接,链接到/usr/bin,具体链接如下:
[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
方法四:Ubuntu 上使用apt-get安装JDK
1.查看apt库都有哪些jdk版本
root@linuxidc:~# 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)
2.选择版本进行安装
root@linuxidc:~# apt-get install openjdk-7-jdk
3.设置环境变量
root@linuxidc:~# vi /etc/profile
在打开的profile文件中添加如下内容
#set java environment
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
JRE_HOME=<span style="display: inline-block; position: relative; width: 16.213em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(2.077em, 1016.13em, 3.397em, -1000em); top: -2.987em; left: 0em;"><span id="MathJax-Span-201" class="mrow"><span id="MathJax-Span-202" class="mi" style="font-family: MathJax_Math; font-style: italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.078em;"><span id="MathJax-Span-203" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-204" class="mi" style="font-family: MathJax_Math; font-style: italic; text-rendering: optimizelegibility;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.186em;"><span id="MathJax-Span-205" class="msubsup"><span style="display: inline-block; position: relative; width: 1.453em; height: 0px;"><span style="position: absolute; clip: rect(3.124em, 1000.73em, 4.16em, -1000em); top: -4em; left: 0em;"><span id="MathJax-Span-206" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span style="display: inline-block; width: 0px; height: 4em;"><span style="position: absolute; top: -3.85em; left: 0.75em;"><span id="MathJax-Span-207" class="mi" style="font-size: 70.7%; font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.04em;"><span style="display: inline-block; width: 0px; height: 4em;"><span id="MathJax-Span-208" class="mi" style="font-family: MathJax_Math; font-style: italic;">O<span id="MathJax-Span-209" class="mi" style="font-family: MathJax_Math; font-style: italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.081em;"><span id="MathJax-Span-210" class="mi" style="font-family: MathJax_Math; font-style: italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.026em;"><span id="MathJax-Span-211" class="texatom"><span id="MathJax-Span-212" class="mrow"><span id="MathJax-Span-213" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-214" class="mi" style="font-family: MathJax_Math; font-style: italic;">j<span id="MathJax-Span-215" class="mi" style="font-family: MathJax_Math; font-style: italic;">r<span id="MathJax-Span-216" class="mi" style="font-family: MathJax_Math; font-style: italic;">e<span id="MathJax-Span-217" class="mi" style="font-family: MathJax_Math; font-style: italic;">C<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.045em;"><span id="MathJax-Span-218" class="mi" style="font-family: MathJax_Math; font-style: italic;">L<span id="MathJax-Span-219" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-220" class="mi" style="font-family: MathJax_Math; font-style: italic;">S<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.032em;"><span id="MathJax-Span-221" class="msubsup"><span style="display: inline-block; position: relative; width: 1.219em; height: 0px;"><span style="position: absolute; clip: rect(3.135em, 1000.65em, 4.182em, -1000em); top: -4em; left: 0em;"><span id="MathJax-Span-222" class="mi" style="font-family: MathJax_Math; font-style: italic;">S<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.032em;"><span style="display: inline-block; width: 0px; height: 4em;"><span style="position: absolute; top: -3.85em; left: 0.613em;"><span id="MathJax-Span-223" class="mi" style="font-size: 70.7%; font-family: MathJax_Math; font-style: italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.077em;"><span style="display: inline-block; width: 0px; height: 4em;"><span id="MathJax-Span-224" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-225" class="mi" style="font-family: MathJax_Math; font-style: italic;">T<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.12em;"><span id="MathJax-Span-226" class="mi" style="font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.057em;"><span id="MathJax-Span-227" class="mo" style="font-family: MathJax_Main; padding-left: 0.278em;">=<span id="MathJax-Span-228" class="mo" style="font-family: MathJax_Main;">.<span id="MathJax-Span-229" class="mo" style="font-family: MathJax_Main; padding-left: 0.167em;">:
JAVA_HOME/lib/dt.jar:<span style="display: inline-block; position: relative; width: 12.747em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(2.077em, 1012.67em, 3.397em, -1000em); top: -2.987em; left: 0em;"><span id="MathJax-Span-231" class="mrow"><span id="MathJax-Span-232" class="mi" style="font-family: MathJax_Math; font-style: italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.078em;"><span id="MathJax-Span-233" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-234" class="mi" style="font-family: MathJax_Math; font-style: italic; text-rendering: optimizelegibility;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.186em;"><span id="MathJax-Span-235" class="msubsup"><span style="display: inline-block; position: relative; width: 1.453em; height: 0px;"><span style="position: absolute; clip: rect(3.124em, 1000.73em, 4.16em, -1000em); top: -4em; left: 0em;"><span id="MathJax-Span-236" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span style="display: inline-block; width: 0px; height: 4em;"><span style="position: absolute; top: -3.85em; left: 0.75em;"><span id="MathJax-Span-237" class="mi" style="font-size: 70.7%; font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.04em;"><span style="display: inline-block; width: 0px; height: 4em;"><span id="MathJax-Span-238" class="mi" style="font-family: MathJax_Math; font-style: italic;">O<span id="MathJax-Span-239" class="mi" style="font-family: MathJax_Math; font-style: italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.081em;"><span id="MathJax-Span-240" class="mi" style="font-family: MathJax_Math; font-style: italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.026em;"><span id="MathJax-Span-241" class="texatom"><span id="MathJax-Span-242" class="mrow"><span id="MathJax-Span-243" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-244" class="mi" style="font-family: MathJax_Math; font-style: italic;">l<span id="MathJax-Span-245" class="mi" style="font-family: MathJax_Math; font-style: italic;">i<span id="MathJax-Span-246" class="mi" style="font-family: MathJax_Math; font-style: italic;">b<span id="MathJax-Span-247" class="texatom"><span id="MathJax-Span-248" class="mrow"><span id="MathJax-Span-249" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-250" class="mi" style="font-family: MathJax_Math; font-style: italic;">t<span id="MathJax-Span-251" class="mi" style="font-family: MathJax_Math; font-style: italic;">o<span id="MathJax-Span-252" class="mi" style="font-family: MathJax_Math; font-style: italic;">o<span id="MathJax-Span-253" class="mi" style="font-family: MathJax_Math; font-style: italic;">l<span id="MathJax-Span-254" class="mi" style="font-family: MathJax_Math; font-style: italic;">s<span id="MathJax-Span-255" class="mo" style="font-family: MathJax_Main;">.<span id="MathJax-Span-256" class="mi" style="font-family: MathJax_Math; font-style: italic; padding-left: 0.167em;">j<span id="MathJax-Span-257" class="mi" style="font-family: MathJax_Math; font-style: italic;">a<span id="MathJax-Span-258" class="mi" style="font-family: MathJax_Math; font-style: italic;">r<span id="MathJax-Span-259" class="mo" style="font-family: MathJax_Main; padding-left: 0.278em;">:JRE_HOME/lib
PATH=<span style="display: inline-block; position: relative; width: 3.627em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(2.111em, 1003.55em, 3.147em, -1000em); top: -2.987em; left: 0em;"><span id="MathJax-Span-261" class="mrow"><span id="MathJax-Span-262" class="mi" style="font-family: MathJax_Math; font-style: italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"><span id="MathJax-Span-263" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-264" class="mi" style="font-family: MathJax_Math; font-style: italic;">T<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.12em;"><span id="MathJax-Span-265" class="mi" style="font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.057em;"><span id="MathJax-Span-266" class="mo" style="font-family: MathJax_Main; padding-left: 0.278em;">:
JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效
root@linuxidc:~# source /etc/profile
4.验证(同上一方法)
二、查看安装路径:
总结一下如何查找JDK安装路径的方法
首先声明,echo <span style="display: inline-block; position: relative; width: 30.72em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(2.027em, 1030.72em, 3.397em, -1000em); top: -2.987em; left: 0em;"><span id="MathJax-Span-268" class="mrow"><span id="MathJax-Span-269" class="mi" style="font-family: MathJax_Math; font-style: italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.078em;"><span id="MathJax-Span-270" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span id="MathJax-Span-271" class="mi" style="font-family: MathJax_Math; font-style: italic; text-rendering: optimizelegibility;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.186em;"><span id="MathJax-Span-272" class="msubsup"><span style="display: inline-block; position: relative; width: 1.453em; height: 0px;"><span style="position: absolute; clip: rect(3.124em, 1000.73em, 4.16em, -1000em); top: -4em; left: 0em;"><span id="MathJax-Span-273" class="mi" style="font-family: MathJax_Math; font-style: italic;">A<span style="display: inline-block; width: 0px; height: 4em;"><span style="position: absolute; top: -3.85em; left: 0.75em;"><span id="MathJax-Span-274" class="mi" style="font-size: 70.7%; font-family: MathJax_Math; font-style: italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.04em;"><span style="display: inline-block; width: 0px; height: 4em;"><span id="MathJax-Span-275" class="mi" style="font-family: MathJax_Math; font-style: italic;">O<span id="MathJax-Span-276" class="mi" style="font-family: MathJax_Math; font-style: italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.081em;"><span id="MathJax-Span-277" class="mi" style="font-family: MathJax_Math; font-style: italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.026em;"><span id="MathJax-Span-278" class="texatom"><span id="MathJax-Span-279" class="mrow"><span id="MathJax-Span-280" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">方<span id="MathJax-Span-281" class="texatom"><span id="MathJax-Span-282" class="mrow"><span id="MathJax-Span-283" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">法<span id="MathJax-Span-284" class="texatom"><span id="MathJax-Span-285" class="mrow"><span id="MathJax-Span-286" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">是<span id="MathJax-Span-287" class="texatom"><span id="MathJax-Span-288" class="mrow"><span id="MathJax-Span-289" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">在<span id="MathJax-Span-290" class="texatom"><span id="MathJax-Span-291" class="mrow"><span id="MathJax-Span-292" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">已<span id="MathJax-Span-293" class="texatom"><span id="MathJax-Span-294" class="mrow"><span id="MathJax-Span-295" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">经<span id="MathJax-Span-296" class="texatom"><span id="MathJax-Span-297" class="mrow"><span id="MathJax-Span-298" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">配<span id="MathJax-Span-299" class="texatom"><span id="MathJax-Span-300" class="mrow"><span id="MathJax-Span-301" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">置<span id="MathJax-Span-302" class="texatom"><span id="MathJax-Span-303" class="mrow"><span id="MathJax-Span-304" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">了<span id="MathJax-Span-305" class="texatom"><span id="MathJax-Span-306" class="mrow"><span id="MathJax-Span-307" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-308" class="mi" style="font-family: MathJax_Math; font-style: italic;">e<span id="MathJax-Span-309" class="mi" style="font-family: MathJax_Math; font-style: italic;">t<span id="MathJax-Span-310" class="mi" style="font-family: MathJax_Math; font-style: italic;">c<span id="MathJax-Span-311" class="texatom"><span id="MathJax-Span-312" class="mrow"><span id="MathJax-Span-313" class="mo" style="font-family: MathJax_Main;">/<span id="MathJax-Span-314" class="mi" style="font-family: MathJax_Math; font-style: italic;">p<span id="MathJax-Span-315" class="mi" style="font-family: MathJax_Math; font-style: italic;">r<span id="MathJax-Span-316" class="mi" style="font-family: MathJax_Math; font-style: italic;">o<span id="MathJax-Span-317" class="mi" style="font-family: MathJax_Math; font-style: italic;">f<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.06em;"><span id="MathJax-Span-318" class="mi" style="font-family: MathJax_Math; font-style: italic;">i<span id="MathJax-Span-319" class="mi" style="font-family: MathJax_Math; font-style: italic;">l<span id="MathJax-Span-320" class="mi" style="font-family: MathJax_Math; font-style: italic;">e<span id="MathJax-Span-321" class="texatom"><span id="MathJax-Span-322" class="mrow"><span id="MathJax-Span-323" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">文<span id="MathJax-Span-324" class="texatom"><span id="MathJax-Span-325" class="mrow"><span id="MathJax-Span-326" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">件<span id="MathJax-Span-327" class="texatom"><span id="MathJax-Span-328" class="mrow"><span id="MathJax-Span-329" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">的<span id="MathJax-Span-330" class="texatom"><span id="MathJax-Span-331" class="mrow"><span id="MathJax-Span-332" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">前<span id="MathJax-Span-333" class="texatom"><span id="MathJax-Span-334" class="mrow"><span id="MathJax-Span-335" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">提<span id="MathJax-Span-336" class="texatom"><span id="MathJax-Span-337" class="mrow"><span id="MathJax-Span-338" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">下<span id="MathJax-Span-339" class="texatom"><span id="MathJax-Span-340" class="mrow"><span id="MathJax-Span-341" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">查<span id="MathJax-Span-342" class="texatom"><span id="MathJax-Span-343" class="mrow"><span id="MathJax-Span-344" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">询<span id="MathJax-Span-345" class="texatom"><span id="MathJax-Span-346" class="mrow"><span id="MathJax-Span-347" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">的<span id="MathJax-Span-348" class="texatom"><span id="MathJax-Span-349" class="mrow"><span id="MathJax-Span-350" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">,<span id="MathJax-Span-351" class="texatom"><span id="MathJax-Span-352" class="mrow"><span id="MathJax-Span-353" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">如<span id="MathJax-Span-354" class="texatom"><span id="MathJax-Span-355" class="mrow"><span id="MathJax-Span-356" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">果<span id="MathJax-Span-357" class="texatom"><span id="MathJax-Span-358" class="mrow"><span id="MathJax-Span-359" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">该<span id="MathJax-Span-360" class="texatom"><span id="MathJax-Span-361" class="mrow"><span id="MathJax-Span-362" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">文<span id="MathJax-Span-363" class="texatom"><span id="MathJax-Span-364" class="mrow"><span id="MathJax-Span-365" class="mo"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">件
JAVA_HOME配置错误,输出结果也是错误的。
其次,which java查询到的是java的执行路径,不是安装路径!!(以前我一直搞不清楚。。。面壁...)
再者,whereis java 也不能查询到安装路径,它就罗列出一堆包含java的文件,对查找安装路径一点用都没有!!!
最后,开始高潮部分:
另附上/etc/profile配置详细格式,
然后,source /etc/profile 使之立即生效。
在centos7的terminal中输入Java -verison是没问题的,但是javac的话就会提示没有此命令
百度了好久,说的很复杂,照着做了,最后也没有成功
后来在stackoverflow上看到了这个
84 down voteaccepted
|
You installed the Java Runtime Environment (JRE) only, which does not contain By the way: you can find out which package provides
Another note: using |
大意就是我们用yum来装原生的就行了
使用
yum install java-devel