赞
踩
# cd /etc/alternatives
# ll
如下图:
java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-1.el7.x86_64/jre/bin/java
或者 使用以下命令输出:
# ls -lrt /etc/alternatives/java
lrwxrwxrwx. 1 root root 71 Apr 30 09:45 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-1.el7.x86_64/jre/bin/java
# rpm -qa|grep openjdk -i
java-1.8.0-openjdk-headless-1.8.0.262.b10-1.el7.x86_64
java-1.8.0-openjdk-1.8.0.262.b10-1.el7.x86_64
#
# find / -name java-1.8.0-openjdk-1.8.0.262.b10-1.el7.x86_64
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-1.el7.x86_64
/usr/lib/jvm-exports/java-1.8.0-openjdk-1.8.0.262.b10-1.el7.x86_64
/usr/lib/jvm-private/java-1.8.0-openjdk-1.8.0.262.b10-1.el7.x86_64
#
[root@localhost lib]# javac
bash: javac: command not found...
Similar command is: 'java'
[root@localhost lib]#
无网建议卸载自带jdk和jre,安装统一版本的离线jdk
)[root@localhost lib]# yum search java|grep jdk ldapjdk-javadoc.noarch : Javadoc for ldapjdk ...... ...... java-1.8.0-openjdk.i686 : OpenJDK Runtime Environment 8 java-1.8.0-openjdk.x86_64 : OpenJDK 8 Runtime Environment java-1.8.0-openjdk-accessibility.i686 : OpenJDK accessibility connector java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector java-1.8.0-openjdk-demo.i686 : OpenJDK Demos 8 java-1.8.0-openjdk-demo.x86_64 : OpenJDK 8 Demos java-1.8.0-openjdk-devel.i686 : OpenJDK Development Environment 8 java-1.8.0-openjdk-devel.x86_64 : OpenJDK 8 Development Environment java-1.8.0-openjdk-headless.i686 : OpenJDK Headless Runtime Environment 8 java-1.8.0-openjdk-headless.x86_64 : OpenJDK 8 Headless Runtime Environment java-1.8.0-openjdk-javadoc.noarch : OpenJDK 8 API documentation java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK 8 API documentation compressed java-1.8.0-openjdk-src.i686 : OpenJDK Source Bundle 8 java-1.8.0-openjdk-src.x86_64 : OpenJDK 8 Source Bundle ...... ...... ldapjdk.noarch : The Mozilla LDAP Java SDK [root@localhost lib]#
附(参考):
(1)单独安装jre命令:yum install java-1.8.0-openjdk
(2)单独安装jdk命令:yum install java-1.8.0-openjdk-devel.x86_64
执行以下命令可安装或升级默认jre:
# yum install java-1.8.0-openjdk
建议版本与jre版本保持一致
)# yum install java-1.8.0-openjdk-devel.x86_64
查看安装软件,如下图:
# rpm -qa|grep java-1.8.0-openjdk -i
jdk安装目录如下:
# vim /etc/profile
(1)配置/etc/profile文件,在最后添加jdk配置信息
# jdk config
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64
export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
重启加载环境变量配置,测试javac命令
[root@localhost jvm]# source /etc/profile
[root@localhost jvm]#
[root@localhost jvm]# javac
...
...
[root@localhost jvm]#
[root@localhost jvm]# javac -version
javac 1.8.0_322
[root@localhost jvm]#
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。