Centos下編譯JDK

來源:互聯網
上載者:User

標籤:

因為OpenJDK是開源的,這裡使用openJDK進行編譯聯絡

環境要求
  • Centos6.7 64位
  • openjdk-7u40-fcs-src-b43-26_aug_2013.zip
  • bootstrap JDK:  jdk1.6.0_38

因為我們是編譯,所以環境的話可以根據自己的實際情況進行調整,JDK的源碼包可以去這個網站進行下載https://jdk7.java.net/source.html

boostrap JDK:輔助JDK,意思是我們要編譯一個新的JDK時需要別的JDK來輔助完成,就像點火需要打火機一樣。

編譯前的準備

因為要進行編譯所以需要安裝相應的編譯工具

  • 安裝gcc、gcc-c++

  yum install -y gcc gcc-c++

  • 安裝cups-devel (unix列印系統)

  yum install -y cups-devel  

  • 安裝alsa-lib-devel

  yum install -y alsa-lib-devel

  • 安裝X圖形庫

  yum install -y libXrender libXrender-devel libXi-devel libXt-devel libXtst-devel

  • 安裝freetype字型庫

  yum install -y freetype freetype-devel

  • 安裝bootstrap JDK

    yum install -y java-1.6.0-openjdk java-1.6.0-openjdk-devel

  • 安裝ant

  yum install -y ant ant-nodeps

設定環境變數

 編譯JDK時不同通過讀取設定檔來看使用者做了那些定製,而是用過讀取當前shell的環境變數來看設定的。在設定環境變數時可以參考以下指令碼

因為我們是要研究java虛擬機器的所以這裡開啟DEBUG模式

#!/bin/bash#clear settings if you have ever setup unset CLASSPAHTunset JAVA_HOME#select language, required export LANG=C#bootsrap JDK path installed, requiredexport ALT_BOOTDIR=/usr/local/jdk1.7.0_79#setup freetypeexport ALT_FREETYPE_LIB_PATH=/usr/local/libexport ALT_FREETYPE_HEADERS_PATH=/usr/local/include
#setup ant pathexport ANT_HOME=/root/apache-ant-1.9.7#dowload dependencies automaticallyexport ALLOW_DOWNLOADS=ture#setup number of compiled threads same to cpusexport HOTSPOT_BUILD_JOBS=1export ALT_PARALLEL_COMPILE_JOBS=1export SKIP_COMPARE_IMAGES=trueexport USE_PRECOMPILED_HEADER=true#setup what you want to compileexport BUILD_LANGTOOLS=true#export BUILD_JAXP=false#export BUILD_JAXWS=false#export BUILD_CORBA=falseexport BUILD_HOTSPOT=trueexport BUILD_JDK=true#setup arch=64 if your cpu is 64 or arch=32export ARCH_DATA_MODEL=64#setup version#export SKIP_DEBUG_BUILD=false#export SKIP_FASTDEBUG_BUILD=true#export DEBUG_NAME=debugBUILD_DEPLOY=false#cancel build install packageBUILD_INSTALL=false#setup output DIRexport ALT_OUTPUTDIR=/usr/local/jdk7-dev/build

 注意:在執行指令碼時使用source命令執行 source setenv.sh

編譯環境檢查

當我們設定好環境變數後如果看我們的設定是否正確

進入源碼的根目錄,執行make sanity,如果結果如下則表示環境設定成功

編譯

在源碼的根目錄執行make all就可以進行編譯了

 

Centos下編譯JDK

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.