惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
Cisco Talos Blog
Cisco Talos Blog
Latest news
Latest news
P
Proofpoint News Feed
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
S
Securelist
T
Tor Project blog
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
NISL@THU
NISL@THU
C
CERT Recently Published Vulnerability Notes
L
LINUX DO - 热门话题
V
Vulnerabilities – Threatpost
Simon Willison's Weblog
Simon Willison's Weblog
AWS News Blog
AWS News Blog
T
The Blog of Author Tim Ferriss
Security Latest
Security Latest
P
Proofpoint News Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tenable Blog
博客园_首页
TaoSecurity Blog
TaoSecurity Blog
Attack and Defense Labs
Attack and Defense Labs
Project Zero
Project Zero
The Hacker News
The Hacker News
M
MIT News - Artificial intelligence
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
K
Kaspersky official blog
F
Full Disclosure
WordPress大学
WordPress大学
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
N
Netflix TechBlog - Medium
Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MongoDB | Blog
MongoDB | Blog
宝玉的分享
宝玉的分享
GbyAI
GbyAI
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements
博客园 - 叶小钗
Webroot Blog
Webroot Blog
Hacker News: Ask HN
Hacker News: Ask HN

陈少文的网站

巨变与机遇的未来十年 Kubernetes 平台管理软件压力测试方案 使用镜像部署 Hexo 静态页面 终于等到你 - GitHub 镜像仓库服务(ghcr.io) 一起来学 Go --(6)Interface 一起来学 Go --(5)Goroutine 和 Channel 什么是函数式编程 如何在 Kubernetes 集群集成 Kata 柯里化与偏函数 使用 PyGithub 自动创建 Label 软件产品是团队能力的输出 Helm 2 、Helm 3 比较 IoT 变现 Kubernetes 中的 DNS 服务 国内的 Helm 镜像源 Harbor 使用自签证书支持 Https 访问 DevOps 工具链之 Prow 如何使用 kfctl 安装 Kubeflow VS Code 无法下载 Go 插件的工具包 工程师更应具有服务精神 你不知道的 Docker 使用技巧 使用 Docker 运行 Tensorflow 论中国 什么是左移 如何清空 Git 仓库全部历史记录 一禅小和尚 有风吹过厨房 时间的玫瑰 如何在 CentOS 安装 GPU 驱动 开发 Tips(19) 使用 Velero 备份 Kubernetes 集群 Kubernetes Cheat Sheet 开发 Tips(18) 如何构建一个 Java 工程 开发 Tips(17) KubeSpray 安装 Kubernetes 报错 ip in ansible_all_ipv4_addresses 基于 Kubernetes 和 Jenkins 搭建自动化测试系统 在 Kubernetes 上动态创建 Jenkins Slave 使用 Jenkins 进行服务拨测 开发 Tips(16) Kubernetes 签发 Ingress 证书及日常故障运维 Kubernetes 中 Deployment 的基本操作 Kubernetes 中的证书 如何使用 KubeBuilder 开发一个 Operator Kubernetes 1.6.0 安装问题汇总 镜像管理工具 -- Harbor 开发 Tips(15) Docker 如何拉取镜像 开发 Tips(14) 使用 Helm 安装 harbor 开发 Tips(13) 使用 S2I 构建云原生应用 在 Kubernetes 中使用 emptyDir、hostPath、localVolume 开发 Tips(12) 开发 Tips(11) 代码质量分析工具 SonarQube 使用 Kubeadm 安装 Kubernetes 集群 一起来学 Go --(4)常用函数 Kubernetes 中的 Ceph Kubernetes 之 Volumes Kubernetes 之 Labels、Selectors 开发 Tips(10) 开源正在重构商业模式 Kubernetes 之网络 Kubernetes 之 API 使用 Helm 和 Operator 快速部署 Prometheus Kubernetes 复杂有状态应用管理框架 -- Operator Kubernetes 的包管理器 -- Helm 一起来学 Go --(3)Go Modules 如何一步一步地优化博客方案 kubectl 实用指南 Kubernetes 中的基本概念 搭建远程 Kubernetes 开发环境 大公司和小公司的 ToB 思路 开发 Tips(9) Go 入门指南 一起来学 Go --(2)数据与逻辑结构 如何预防 Web 富文本中的 XSS 攻击 django-xss-cleaner 云工作时代 一起来学 Go --(1)背景与特点 SaaS 开发团队的不同阶段 你不知道的 Git 使用技巧 输出既服务 微服务设计 继续奔跑 开发 Tips(8) 从账户安全到二次验证 Django 性能之数据库查询优化 Django 性能之分库分表 敏捷开发之研发流程 打造一致性的团队 开发 Tips(7) Pytest 进阶学习之 Mock PaaS 部署之 buildpack Go 开发配置 领域输出才是 PaaS 的核心竞争力 Pytest 入门学习 开发 Tips(6) 如何使用 Jenkins、Docker、GitLab 搭建 Django 自动化部署流程
CentOS 7 安装 Java 开发环境
微信公众号 · 2020-07-01 · via 陈少文的网站

1. 编译报错:java.nio.file.NoSuchFileException

在编译 Jenkins 插件时,提示错误信息如下:

1
2
3
4
mvn package

Compilation failure
[ERROR] java.nio.file.NoSuchFileException: /root/java/target/classes/META-INF/annotations/hudson.Extension

原来 Maven 使用的是 JAVA_HOME 而不是 PATH,找不到 Java 运行环境导致,而且 Java 11 不行,Java 1.8 才能正常编译。

2. 安装 JDK

  • 安装 Java 11
1
yum install -y java-11-openjdk-devel
  • 安装 Java 1.8
1
yum install -y java-1.8.0-openjdk-devel

3. 选择 JDK 版本

选择当前 JDK 版本:

1
2
3
4
5
6
7
8
alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.7.10-4.el7_8.x86_64/bin/java)
*+ 2           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/jre/bin/java)

选择 2 之后, /usr/lib/jvm/java-openjdk 即为当前选择的版本。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
ls -l /usr/lib/jvm

lrwxrwxrwx 1 root root   26 Jul  1 15:42 java -> /etc/alternatives/java_sdk
lrwxrwxrwx 1 root root   29 Jul  1 15:42 java-11 -> /etc/alternatives/java_sdk_11
lrwxrwxrwx 1 root root   37 Jul  1 15:42 java-11-openjdk -> /etc/alternatives/java_sdk_11_openjdk
drwxr-xr-x 8 root root 4096 Jul  1 15:42 java-11-openjdk-11.0.7.10-4.el7_8.x86_64
lrwxrwxrwx 1 root root   34 Jul  1 15:42 java-openjdk -> /etc/alternatives/java_sdk_openjdk
lrwxrwxrwx 1 root root   21 Jul  1 16:01 jre -> /etc/alternatives/jre
lrwxrwxrwx 1 root root   24 Jul  1 15:42 jre-11 -> /etc/alternatives/jre_11
lrwxrwxrwx 1 root root   32 Jul  1 15:42 jre-11-openjdk -> /etc/alternatives/jre_11_openjdk
lrwxrwxrwx 1 root root   40 Jul  1 15:42 jre-11-openjdk-11.0.7.10-4.el7_8.x86_64 -> java-11-openjdk-11.0.7.10-4.el7_8.x86_64
lrwxrwxrwx 1 root root   29 Jul  1 15:42 jre-openjdk -> /etc/alternatives/jre_openjdk

查看 Java 版本:

1
2
3
4
5
java -version

openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode

4. 配置环境变量

编辑文件

添加环境变量

1
2
export JAVA_HOME=/usr/lib/jvm/java-openjdk
export JRE_HOME=/usr/lib/jvm/jre-openjdk

使环境变量生效

5. 卸载 JDK

查看当前环境安装的 JDK :

1
2
3
4
5
6
7
8
9
rpm -aq | grep -i jdk

copy-jdk-configs-3.3-10.el7_5.noarch
java-1.8.0-openjdk-headless-1.8.0.252.b09-2.el7_8.x86_64
java-11-openjdk-headless-11.0.7.10-4.el7_8.x86_64
java-11-openjdk-devel-11.0.7.10-4.el7_8.x86_64
java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
java-11-openjdk-11.0.7.10-4.el7_8.x86_64
java-1.8.0-openjdk-devel-1.8.0.252.b09-2.el7_8.x86_64

不需要一个一个删除,只需要删除 copy-jdk-configs 即可。

1
yum remove -y copy-jdk-configs-3.3-10.el7_5.noarch