当前位置:   article > 正文

Linux7查看默认jdk安装目录(默认只有jre环境,无jdk开发环境。附:安装jdk并配置JAVA_HOME)_linux的jdk安装在哪个目录

linux的jdk安装在哪个目录

1、检测默认jre运行环境

(1) 查看linux7默认运行环境jre

# cd /etc/alternatives
# ll
  • 1
  • 2

如下图:
在这里插入图片描述
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
#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

(2) 检测开发环境jdk

[root@localhost lib]# javac
bash: javac: command not found...
Similar command is: 'java'
[root@localhost lib]# 
  • 1
  • 2
  • 3
  • 4

(3) 联网安装开发环境jdk(无网建议卸载自带jdk和jre,安装统一版本的离线jdk

3.1)检测yum源存在的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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

附(参考):
(1)单独安装jre命令:yum install java-1.8.0-openjdk
(2)单独安装jdk命令:yum install java-1.8.0-openjdk-devel.x86_64


3.2)yum方式安装jdk

执行以下命令可安装或升级默认jre:

# yum install java-1.8.0-openjdk
  • 1

3.3)yum方式安装jdk(建议版本与jre版本保持一致

# yum install java-1.8.0-openjdk-devel.x86_64
  • 1

查看安装软件,如下图:

# rpm -qa|grep java-1.8.0-openjdk -i
  • 1

在这里插入图片描述
jdk安装目录如下:
在这里插入图片描述


3、配置JAVA_HOME

# vim /etc/profile
  • 1

(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
  • 1
  • 2
  • 3
  • 4
  • 5

重启加载环境变量配置,测试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]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/187452
推荐阅读
相关标签
  

闽ICP备14008679号