为了账号安全,请及时绑定邮箱和手机立即绑定

优雅地在Mac OS Catalina下 编译 Open JDK 13

标签:
Java C JVM

1 系统环境https://img1.sycdn.imooc.com//5da8887600014f7711720734.jpg

Xcode Oracle JDK: 13

先确保系统已安装freetype和ccache

  • freetype: 2.9

  • ccache: 3.3.5

$ brew install freetype ccache

2 下载源码

通过Mercurial代码管理版本管理工具从Repository中直接获取源码(Repository为http://hg.openjdk.java.net)https://img1.sycdn.imooc.com//5da888770001290233520726.jpg

3 自动检测依赖

进入解压后的文件夹,然后运行bash ./configure。这是一项检测所需要的依赖是否安装好了的脚本。只需要根据其提供的错误提示,将相应错误修改完成即可。

4 配置参数

参数说明

--with-debug-level=slowdebug 启用slowdebug级别调试--enable-dtrace 启用dtrace--with-jvm-variants=server 编译server类型JVM--with-target-bits=64 指定JVM为64位--enable-ccache 启用ccache,加快编译--with-num-cores=8 编译使用CPU核心数--with-memory-size=8000 编译使用内存--disable-warnings-as-errors 忽略警告
bash configure 
--with-debug-level=slowdebug --enable-dtrace --with-jvm-variants=server --with-target-bits=64 --enable-ccache --with-num-cores=8 --with-memory-size=8000 --disable-warnings-as-errors

https://img1.sycdn.imooc.com//5da888790001d41833540170.jpg

  • 直接报错https://img1.sycdn.imooc.com//5da888790001ed2333540310.jpg

    configure: error: No xcodebuild tool and no system framework headers found, use --with-sysroot or --with-sdk-name to provide a path to a valid SDK

    运行了一下xcodebuild,错误信息如下:

xcode-select: error: tool 'xcodebuild' requires Xcode, 
but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

https://img1.sycdn.imooc.com//5da888790001aae233580196.jpg

  • 解决方案

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

https://img1.sycdn.imooc.com//5da8887a0001968322700200.jpg

  • 继续执行bash configure得到如下https://img1.sycdn.imooc.com//5da8887a0001d01933561218.jpg

5 开始编译

make image

https://img1.sycdn.imooc.com//5da8887c00018dbf16880460.jpghttps://img1.sycdn.imooc.com//5da8887d0001c19818200768.jpg完成了!

6 验证

https://img1.sycdn.imooc.com//5da8887d0001385f33540334.jpg

7 Clion 导入项目

  • 选择ok

    8 编辑配置

    如下图编辑DEBUG配置信息

  • Executable 选择之前build出的镜像里的java可执行文件

  • Program arguments 填写-version,输出Java版本

  • Before launch 注意:这里一定要移除Build,否则会报错无法调试


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
JAVA开发工程师
手记
粉丝
1.4万
获赞与收藏
1461

关注作者,订阅最新文章

阅读免费教程

  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消