CentOS7安装Jdk1.8
一、前期准备
a) 首先从官网上下载Jdk 8 for Linux x64到window下。
b) 我这边用的最小安装,所以没有安装centos自带的openjdk,如果你安装时,不是最小安装的话,可能集成了系统的openjdk,所以我们先要删除自带的openjdk,具体步骤如下:
1) 在系统终端输入:rpm -qa | grep java,如果有openjdk的话,会出现类似于XXXX_openjdk_XXX的信息。(可能有多条)
2) 删除openjdk,在终端输入:rpm -e –-nodeps XXXX_openjdk_XXX 。即可删除自带的openjdk。(如果有多条openjdk,依次执行命令删除)
rpm -e --nodeps `rpm -qa | grep java`
二、Jdk的安装
a) 我们登录超级用户
su root 之后会提示输入密码。
进入www(路径可以自己选择)
1 | cd www |
1 | mkdir javaweb |
b) 我们进入javaweb,:
c) 解压jdk压缩包
1 | tar –xzvf jdk-8u45-linux-x64.gz |
e) 进入jdk1.8.0_161文件夹,输入pwd 获取目录jdk1.8.0_161绝对路径
cd jdk1.8.0_161
1 | pwd |
/www/javaweb/jdk1.8.0_161
三、jdk的配置
a) 使用vim命令打开系统的环境变量配置文件:
vi /etc/profile
b) 在profile文件最后加入:
## JAVA
export JAVA_HOME=jdk的绝对路径(我的是:/www/javaweb/jdk1.8.0_161)
export PATH=$PATH:$JAVA_HOME/bin
c) 使profile生效
source /etc/profile
四、配置验证
a) 首先,我们输入java –version,会得到:
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
b) 我们再输入javac,会得出:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | Usage: javac <options> <source files> where possible options include: -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings -verbose Output messages about what the compiler is doing -deprecation Output source locations where deprecated APIs are used -classpath <path> Specify where to find user class files and annotation processors -cp <path> Specify where to find user class files and annotation processors -sourcepath <path> Specify where to find input source files -bootclasspath <path> Override location of bootstrap class files -extdirs <dirs> Override location of installed extensions -endorseddirs <dirs> Override location of endorsed standards path -proc:{none,only} Control whether annotation processing and/or compilation is done. -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process -processorpath <path> Specify where to find annotation processors -parameters Generate metadata for reflection on method parameters -d <directory> Specify where to place generated class files -s <directory> Specify where to place generated source files -h <directory> Specify where to place generated native header files -implicit:{none, class } Specify whether or not to generate class files for implicitly referenced files -encoding <encoding> Specify character encoding used by source files -source <release> Provide source compatibility with specified release -target <release> Generate class files for specific VM version -profile <profile> Check that API used is available in the specified profile -Werror Terminate compilation if warnings occur @<filename> Read options and filenames from file |
c) 如果得到以上两步正确结果的话,恭喜你,你的jdk8就已经配置好了。
使用docker自定义oraclejdk启动jar包:https://www.cnblogs.com/pxblog/p/15250868.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了